Last modified: 2012-10-30 23:44:46 UTC
I've created two pages with exactly the same code: * https://pt.wikibooks.org/wiki/MediaWiki:Gadget-EnhancedSearch.js/Core.js * https://pt.wikipedia.org/wiki/MediaWiki:Gadget-EnhancedSearch.js/Core.js and defined one gadget in each project, both with the same definition: * EnhancedSearchCore[ResourceLoader|rights=oculto]|EnhancedSearch.js/Core.js The one at ptwikibooks correctly generates a module "ext.gadget.EnhancedSearchCore": * https://bits.wikimedia.org/pt.wikibooks.org/load.php?debug=false&lang=pt&modules=ext.gadget.EnhancedSearchCore&skin=vector&version=20120916T221122Z&* but the one on ptwiki is "empty": * https://bits.wikimedia.org/pt.wikipedia.org/load.php?debug=false&lang=pt&modules=ext.gadget.EnhancedSearchCore&skin=vector&version=20120909T005652Z&* More precisely, it contains only this code: ---- mw.loader.implement("ext.gadget.EnhancedSearchCore",function(){;},{},{}); /* cache key: ptwiki:resourceloader:filter:minify-js:7:afdac18b7c74164d7ddfb2546d8b3023 */ ---- and as such it does nothing when we try to load it with mw.loader.load as a (minified) module: https://pt.wikipedia.org/wiki/MediaWiki:Gadget-EnhancedSearch.js?diff=32178987 Why mw.loader.load gets an empty module on ptwiki? Here are some extra examples: * works: https://bits.wikimedia.org/pt.wikipedia.org/load.php?modules=ext.gadget.Topicon * do not works: https://bits.wikimedia.org/pt.wikipedia.org/load.php?modules=ext.gadget.NewVillagePumpCore
Creating a test at https://pt.wikipedia.org/wiki/MediaWiki:Gadget-RL-test.js?oldid=32251404 with the code console.log(123); and defining a gadget with either of these lines * RL-test[ResourceLoader|rights=hidden]|RL-test.js * RL-test[ResourceLoader|rights=oculto]|RL-test.js at https://pt.wikipedia.org/wiki/MediaWiki:Gadgets-definition?diff=32251437 I was able to load the module correctly using mw.loader.load('ext.gadget.RL-test'); and I saw "123" on Google Chrome's console. Also, the console.log comment appears at https://bits.wikimedia.org/pt.wikipedia.org/load.php?modules=ext.gadget.RL-test as expected. But mw.loader.load('ext.gadget.EnhancedSearchCore'); do not work (it should add some checkboxes at [[pt:Special:Search]], as it does when executed on ptwikibooks's search page), since the code is not here: https://bits.wikimedia.org/pt.wikipedia.org/load.php?modules=ext.gadget.EnhancedSearchCore but is here: https://bits.wikimedia.org/pt.wikibooks.org/load.php?modules=ext.gadget.EnhancedSearchCore
I've purged them. Seems fine now. Not sure why it looked empty. In debug mode it was also fine. Appears to be a caching issue. Perhaps you created the definition entry before the javascript page, and so the empty (non existent) page got into cache?
As you can check at https://pt.wikipedia.org/wiki/Special:Contribs/Rjclaudio?offset=20120909005857&target=Rjclaudio&limit=23&uselang=en at first some existing JavaScript pages were moved * MediaWiki:Gadget-Nova-esplanada.js --> MediaWiki:Gadget-NewVillagePump.js/Core.jsjs --> MediaWiki:Gadget-NewVillagePump.js/Core.js * MediaWiki:Gadget-SVGPNG.js --> MediaWiki:Gadget-SVGPNG.js/Core.js Only after this the definition was changed: https://pt.wikipedia.org/w/index.php?title=MediaWiki:Gadgets-definition&diff=prev&oldid=32157328 (this was the first time we had gadgets with names "NewVillagePumpCore", "EnhancedSearchCore" and "SVGPNGCore" respectively). Then the last script was renamed: * MediaWiki:Gadget-BuscaAprimorada.js --> MediaWiki:Gadget-EnhancedSearch.js/Core.js The modules corresponding to the three gadgets were "empty", but two of them had their JS pages created /before/ the edit to its definition, and the other one was created /after/ being defined. Is this sufficient to discard the "defined before created" hypothesis? Right now the other two modules which we renamed are still empty: 1) https://bits.wikimedia.org/pt.wikipedia.org/load.php?modules=ext.gadget.SVGPNGCore ---- mw.loader.implement("ext.gadget.SVGPNGCore",function(){;},{},{}); /* cache key: ptwiki:resourceloader:filter:minify-js:7:1d3a5dc1bab123e9cf7227f2ddfc35c9 */ ---- 2) https://bits.wikimedia.org/pt.wikipedia.org/load.php?modules=ext.gadget.NewVillagePumpCore ---- mw.loader.implement("ext.gadget.NewVillagePumpCore",function(){;},{},{}); /* cache key: ptwiki:resourceloader:filter:minify-js:7:346ff6bd2ceb3628d57f92830f57b620 */ ----
(In reply to comment #2) > I've purged them. Seems fine now. Not sure why it looked empty. In debug mode > it was also fine. The module you'd purged when you edited the JS page[1] is empty again[2]!!! (we didn't touch it this time...) [1] https://pt.wikipedia.org/wiki/MediaWiki:Gadget-EnhancedSearch.js/Core.js?diff=32254667 [2] https://bits.wikimedia.org/pt.wikipedia.org/load.php?modules=ext.gadget.EnhancedSearchCore
I think ResourceLoader is crazy. It returns random content at https://bits.wikimedia.org/pt.wikipedia.org/load.php?modules=ext.gadget.EnhancedSearchCore Some times the code of the gadget is replaced by "function(){;}" and if I keep reloading that page 50% of the time the code is there and the other 50% it is not (whithout editing any other related pages)
The same randomness happens after I did a small edit on this one: https://pt.wikipedia.org/w/index.php?title=MediaWiki:Gadget-SVGPNG.js/Core.js&diff=32510433 The content of https://bits.wikimedia.org/pt.wikipedia.org/load.php?modules=ext.gadget.SVGPNGCore keeps alternating between ---- mw.loader.implement("ext.gadget.SVGPNGCore",function(){(function($,mw){'use strict';function SVGThumbs(){var thumbu,svgAltSize,p,l,i,info,file=document.getElementById('file'),i18n={'en':'This image rendered as PNG in other sizes: ','pt':'Esta imagem pode ser renderizada em PNG em outros tamanhos: '};if(!file){return;}i18n['en-gb']=i18n.en;i18n['pt-br']=i18n.pt;mw.messages.set({'svg-thumbs-desc':i18n[mw.config.get('wgUserLanguage')]||i18n.en});thumbu=file.getElementsByTagName('IMG')[0].getAttribute('src');if(!thumbu){return;}svgAltSize=function(w,title){var path=thumbu.replace(/\/\d+(px-[^\/]+$)/,'/'+w+'$1'),a=document.createElement('A');a.setAttribute('href',path);a.appendChild(document.createTextNode(title));return a;};p=document.createElement('p');p.className='SVGThumbs';p.appendChild(document.createTextNode(mw.msg('svg-thumbs-desc')));l=[200,500,1000,2000];for(i=0;i<l.length;i++){p.appendChild(svgAltSize(l[i],l[i]+'px'));if(i<l.length-1){p.appendChild(document.createTextNode(', ')); }}p.appendChild(document.createTextNode('.'));info=$(file.parentNode).find('div.fullMedia').get(0);if(info){info.appendChild(p);}}if(mw.config.get('wgNamespaceNumber')===6&&mw.config.get('wgIsArticle')&&mw.config.get('wgTitle').match(/\.svg$/i)){$(SVGThumbs);}}(jQuery,mediaWiki));;},{},{}); /* cache key: ptwiki:resourceloader:filter:minify-js:7:1421d720ab6b220bea3b870ec442b54c */ ---- and ---- mw.loader.implement("ext.gadget.SVGPNGCore",function(){;},{},{}); /* cache key: ptwiki:resourceloader:filter:minify-js:7:1d3a5dc1bab123e9cf7227f2ddfc35c9 */ ----
The module of the other gadget mentioned just keeps empty, even after a small edit like this: https://pt.wikipedia.org/w/index.php?diff=32510516 and various reloads (+-20). On the other hand, when I added "&BUG40288=CONFIRMED" to the URL, the code appeared: https://bits.wikimedia.org/pt.wikipedia.org/load.php?modules=ext.gadget.NewVillagePumpCore&BUG40288=CONFIRMED
We have one more script with the same problem: https://bits.wikimedia.org/pt.wikipedia.org/load.php?debug=true&lang=pt-br&modules=ext.gadget.PagesForDeletionCore&only=scripts&skin=vector&version=20121018T124359Z&* is empty, but it should have the same content of http://pt.wikipedia.org/w/load.php?modules=ext.gadget.PagesForDeletionCore&only=scripts which is the minified version of https://pt.wikipedia.org/wiki/MediaWiki:Gadget-PagesForDeletion.js/Core.js The code is only loaded if we use importScript instead of mw.loader.load: https://pt.wikipedia.org/w/index.php?title=MediaWiki:Gadget-PagesForDeletion.js&diff=32672881 (but this defeats the idea of using RL for minification of the script)
I suspect this is because the JS page has a slash in its name, and the part after the slash isn't a language code. This should be fixed with the cleanup I committed a few weeks ago; this commit is in 1.21wmf2, so it will be rolled out to ptwiki on Wednesday. If the issue persists after Wednesday's deployment, please report back here and I'll investigate.
mybugs.mail: Is this still a problem on ptwiki? (See comment 9.)
It seems to be working. Closing for now.