Page MenuHomePhabricator

Uncaught TypeError: str.replace is not a function
Closed, DuplicatePublic

Description

Error counts between 2016-05-18 20:33:39 and 2016-05-24 17:15:38, for this and similar error messages:

964 Uncaught TypeError: str.replace is not a function
374 TypeError: str.replace is not a function
 41 Uncaught TypeError: Object 0 has no method 'replace'
 29 TypeError: 'undefined' is not a function (evaluating 'str.replace(/([\\\\{}()|.?*+\\-\\^$\\[\\]])/g,'\\\\$1')')
  9 L’objet ne gère pas la propriété ou la méthode « replace »
  5 TypeError: str.replace is not a function. (In 'str.replace(/([\\\\{}()|.?*+\\-\\^$\\[\\]])/g,'\\\\$1')', 'str.replace' is undefined)
  4 オブジェクトは 'replace' プロパティまたはメソッドをサポートしていません。

Event Timeline

matmarex created this task.May 25 2016, 7:37 PM
Restricted Application added a subscriber: Matanya. · View Herald TranscriptMay 25 2016, 7:37 PM

The code this refers to is in mediawiki.RegExp, but we don't use that in UploadWizard. This looks like somebody else's code that runs on all pages.

Judging by the error source URLs we have logged (no backtraces though :( ), only some languages are affected:

https://commons.wikimedia.org/wiki/Special:UploadWizard
https://commons.wikimedia.org/wiki/Special:UploadWizard?setlang=ar
https://commons.wikimedia.org/wiki/Special:UploadWizard?setlang=fa
https://commons.wikimedia.org/wiki/Special:UploadWizard?uselang=arz
https://commons.wikimedia.org/wiki/Special:UploadWizard?uselang=ckb
https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=wle-dz
https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=wle-dz&uselang=ar
https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=wle-iq
https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=wle-iq&uselang=ar
https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=wle-ma
https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=wle-ma&uselang=ar
https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=wle-tn
https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=wlm-dz
https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=wlm-eg
https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&setlang=fa&uselang=fa
https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&uselang=ar
https://commons.wikimedia.org/w/load.php?debug=false&lang=ar&modules=jquery.accessKeyLabel%2Cclient%7Cmediawiki.RegExp%2Cnotify%2Cutil%7Cmediawiki.legacy.wikibits&skin=vector&version=b5e9abd3
https://commons.wikimedia.org/w/load.php?debug=false&lang=arz&modules=jquery.accessKeyLabel%2Cclient%7Cmediawiki.RegExp%2Cnotify%2Cutil%7Cmediawiki.legacy.wikibits&skin=vector&version=b5e9abd
https://commons.wikimedia.org/w/load.php?debug=false&lang=azb&modules=jquery.accessKeyLabel%2Cclient%7Cmediawiki.RegExp%2Cnotify%2Cutil%7Cmediawiki.legacy.wikibits&skin=monobook&version=b5e9a
https://commons.wikimedia.org/w/load.php?debug=false&lang=bn&modules=jquery.accessKeyLabel%2Cclient%7Cmediawiki.RegExp%2Cnotify%2Cutil%7Cmediawiki.legacy.wikibits&skin=vector&version=b5e9abd3
https://commons.wikimedia.org/w/load.php?debug=false&lang=fa&modules=jquery.accessKeyLabel%2Cclient%7Cmediawiki.RegExp%2Cnotify%2Cutil%7Cmediawiki.legacy.wikibits&skin=vector&version=b5e9abd3
https://commons.wikimedia.org/w/load.php?debug=false&lang=ne&modules=jquery.accessKeyLabel%2Cclient%7Cmediawiki.RegExp%2Cnotify%2Cutil%7Cmediawiki.legacy.wikibits&skin=vector&version=b5e9abd3

Actually, we do indirectly use this code, in the date selector.

I think this is the same problem as T135743 (already fixed). I can reproduce this by setting my language to e.g. Arabic and using a version of MediaWiki before 53b92dbca18dbb570cde8cea31c42e418e57140f. These errors stopped appearing after 2016-06-01, which matches the time when that was backported and deployed.

select left(timestamp,8), count(*) from UploadWizardExceptionFlowEvent_11772722 where timestamp>'201509' and event_message like '%str.replace%' group by left(timestamp,8);

+-------------------+----------+
| left(timestamp,8) | count(*) |
+-------------------+----------+
| 20160518          |       47 |
| 20160519          |      349 |
| 20160520          |      149 |
| 20160521          |      221 |
| 20160522          |      242 |
| 20160523          |      273 |
| 20160524          |      139 |
| 20160525          |      222 |
| 20160526          |      194 |
| 20160527          |      236 |
| 20160528          |      305 |
| 20160529          |      212 |
| 20160530          |      237 |
| 20160531          |      456 |
| 20160601          |       38 |
+-------------------+----------+
15 rows in set (5.24 sec)