[go: up one dir, main page]

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&
checkCssHandles @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
(anonymous) @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
fire @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
fireWith @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
fire @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
fireCallbacks @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
addEmbeddedCSS @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
(anonymous) @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
requestAnimationFrame (async)
addEmbeddedCSS @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
execute @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
handlePending @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
markModuleReady @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
runScript @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
checkCssHandles @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
(anonymous) @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
fire @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
fireWith @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
fire @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
fireCallbacks @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
addEmbeddedCSS @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
(anonymous) @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
requestAnimationFrame (async)
addEmbeddedCSS @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
execute @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
implement @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
(anonymous) @ VM784:29
DOMEval @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
globalEval @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
(anonymous) @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
requestIdleCallback (async)
asyncEval @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
work @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
enqueue @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
load @ VM742 load.php?debug=false&lang=de-formal&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&
(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&
script.onload @ VM741 load.php?debug=false&lang=de-formal&modules=startup&>

Event Timeline

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 moved this task from Currently in sprint to Done on the WMDE-TechWish board.