Page MenuHomePhabricator

mediawiki.Title: "title.replace is not a function"
Closed, ResolvedPublicBUG REPORT

Description

What is the problem?

When using the watch/unwatch functionality on Special:Watchlist, I sometimes see:

Uncaught TypeError: title.replace is not a function
    jQuery 2
        parse
        newFromText
    <anonymous> http://dev.wiki.local.wmftest.net:8080/w/resources/src/mediawiki.special.watchlist/watchlist.js?962bc:67
    jQuery 2
        dispatch
        handle
load.php:1448:5

It seems to happen when the title of the page you are watching/unwatching is a number.

The issue appears to occur around here, because it is attempting to call the string function replace() on a number.

Steps to reproduce problem
  1. As one user, edit https://test.wikipedia.org/wiki/100
  2. As another user, add https://test.wikipedia.org/wiki/100 to your watchlist
  3. Go to https://test.wikipedia.org/wiki/Special:Watchlist
  4. Click the x next to https://test.wikipedia.org/wiki/100

Expected behavior: There should be a javascript popup saying you have unwatched the article
Observed behavior: Takes you to https://test.wikipedia.org/wiki/100?action=watch (and you see an error in the browser console)

Environment

Browser: Firefox 78.
Wiki(s): MediaWiki 1.36.0-alpha (36a0784).

Event Timeline

Change 644947 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/core@master] Cast numeric page titles to string

https://gerrit.wikimedia.org/r/644947

Similar issue will occur for the title "null": https://en.wiktionary.org/wiki/null (you'd have to test that on Wiktionary, otherwise the first letter is changed to upper-case and it works fine).

Change 644947 merged by jenkins-bot:
[mediawiki/core@master] Cast numeric page titles to string

https://gerrit.wikimedia.org/r/644947

matmarex assigned this task to Ammarpad.