Page MenuHomePhabricator

Uncaught TypeError: Cannot read property 'replace' of undefined in mediawiki.Title.js
Closed, ResolvedPublic

Description

I suspect the AdvancedSearch extension to cause this. I get it constantly when submitting advanced searches on dewiki. I don't get it when AdvancedSearch is disabled.

Uncaught TypeError: Cannot read property 'replace' of undefined
    at getNamespacePrefix (<anonymous>:179:1720)
    at Title.getNamespacePrefix (<anonymous>:186:88)
    at Title.getPrefixedDb (<anonymous>:186:648)
    at Title.getUrl (<anonymous>:187:108)
    at i (<anonymous>:265:926)
    at <anonymous>:263:927
getNamespacePrefix @ VM784:179
getNamespacePrefix @ VM784:186
getPrefixedDb @ VM784:186
getUrl @ VM784:187
i @ VM784:265
(anonymous) @ VM784:263
requestIdleCallback (async)
./src/index.js @ VM784:263
t @ VM784:244
(anonymous) @ VM784:244
mw.loader.implement.css @ VM784:244
runScript @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:162
checkCssHandles @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:162
(anonymous) @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:162
fire @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:46
fireWith @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:47
fire @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:47
fireCallbacks @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:157
addEmbeddedCSS @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:157
(anonymous) @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:157
requestAnimationFrame (async)
addEmbeddedCSS @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:157
execute @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:163
handlePending @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:159
markModuleReady @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:161
runScript @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:162
checkCssHandles @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:162
(anonymous) @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:162
fire @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:46
fireWith @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:47
fire @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:47
fireCallbacks @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:157
addEmbeddedCSS @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:157
(anonymous) @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:157
requestAnimationFrame (async)
addEmbeddedCSS @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:157
execute @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:163
implement @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:169
(anonymous) @ VM784:29
DOMEval @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:1
globalEval @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:4
(anonymous) @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:166
requestIdleCallback (async)
asyncEval @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:166
work @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:167
enqueue @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:164
load @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:171
(anonymous) @ index.php?advancedSearchOption-original=Michael+Schönitzer+WMDE&search=Michael+Schönitzer+WMDE&title=Spezial:Suche&profile=default&fulltext=1&advancedSearchOption-filetype=&advancedSearch-current={"options"%3A{}%2C"namespaces"%3A["2"%2C"3"%2C"4"]}&ns2=1&ns3=1&ns4=1&searchToken=ccykra0n90yl9xx6u4tssv6y0:11
startUp @ VM741 load.php?debug=false&lang=de-formal&modules=startup&only=scripts&skin=vector:82
script.onload @ VM741 load.php?debug=false&lang=de-formal&modules=startup&only=scripts&skin=vector:82

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 30 2017, 1:54 PM
Tobi_WMDE_SW triaged this task as High priority.Nov 30 2017, 1:54 PM

Also mentioned in T181633#3796620 but IMO unrelated to the main issue described there, so I created a separate task.

I can reproduce this on dewiki but not on testwiki or arwiki.
https://de.wikipedia.org/w/index.php?search=sajkfkhsf&title=Spezial:Suche&go=Go&searchToken=9b23jzqlqvo7c25db38eo60li

dewiki is currently running the .8 branch and arwiki and testwiki are running .10

It could be that this evenings train which pushes .10 to dewiki might fix this issue.

Does not occur with debug=true might be a dependency / load problem.

So I looked into the issue and could also reproduce it. The code that triggers the error is called in the Popups[1] extension [2]. So I only get it when the Popups extension is installed.

The thing wrong at that point seems to be a unset namespace that we try to access here [3]. Since the title constructed in [2] is a title in the Special namespace he seems to fail due to that. The error is gone for example when I remove the Special: prefix at that place.

[1] https://www.mediawiki.org/wiki/Extension:Popups
[2] https://phabricator.wikimedia.org/diffusion/EPOP/browse/master/src/previewBehavior.js;c175cffe9b0ef6c0224ad03b6ca92cea9619cb6f$53
[3] https://phabricator.wikimedia.org/source/mediawiki/browse/master/resources/src/mediawiki/mediawiki.Title.js;0dd7cdb304484f826511db39fcf8552101ed19c5$145

That's how far I got for now. I am not sure if this is something the Popups guys need to fix or if it's on our side. - Since it does not occur with debug=true it still seems load-related.

I can't seem to replicate this... is there a test wiki I can see this on?

Steps to reproduce:

There you should get the error on the JS console.
( in FF starts slightly different TypeError: mw.config.get(...)[namespace] is undefined )

mw.config.get('wgFormattedNamespaces') doesn't contain the special field.

Visit https://de.wikipedia.org/wiki/Wikipedia:Hauptseite or https://de.wikipedia.org/wiki/Spezial:Beobachtungsliste

mw.config.get('wgFormattedNamespaces')[-1]
"Spezial"

When I visit https://de.wikipedia.org/w/index.php?search=&title=Spezial%3AWatchlist

mw.config.get('wgFormattedNamespaces')[-1]
undefined

It looks like AdvancedSearch removes this for some reason:
https://github.com/wikimedia/mediawiki-extensions-AdvancedSearch/blob/d1e9f8ae2b3409aa3ee7f63f0cd16d5d19901561/modules/ext.advancedSearch.init.js#L35

Changing config doesn't seem like a good idea IMO. It should be considered immutable. Why is anything less than 0 being removed?

Change 402027 had a related patch set uploaded (by WMDE-Fisch; owner: WMDE-Fisch):
[mediawiki/extensions/AdvancedSearch@master] Dont manipulate global namespaces

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

It looks like AdvancedSearch removes this for some reason:
https://github.com/wikimedia/mediawiki-extensions-AdvancedSearch/blob/d1e9f8ae2b3409aa3ee7f63f0cd16d5d19901561/modules/ext.advancedSearch.init.js#L35

Changing config doesn't seem like a good idea IMO. It should be considered immutable. Why is anything less than 0 being removed?

Ok, thanks for looking into this. I was not aware of the fact, that we manipulate the global variable with these lines of code.... still seems strange to me. I fixed it in the patch above.

Change 402027 merged by jenkins-bot:
[mediawiki/extensions/AdvancedSearch@master] Don't manipulate global namespaces

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

WMDE-Fisch closed this task as Resolved.
Lea_WMDE moved this task from Done to Demoed on the WMDE-QWERTY-Team board.Feb 20 2018, 3:31 PM