Last modified: 2010-05-07 14:27:59 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T22720, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 20720 - Change script loading order back
Change script loading order back
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
unspecified
All All
: Normal critical with 1 vote (vote)
: ---
Assigned To: Michael Dale
: code-update-regression
Depends on: 23433
Blocks:
  Show dependency treegraph
 
Reported: 2009-09-18 12:05 UTC by Liangent
Modified: 2010-05-07 14:27 UTC (History)
8 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Liangent 2009-09-18 12:05:29 UTC
the new order breaks some scripts.

there are some dependencies among the scripts.
Comment 1 Liangent 2009-09-18 12:12:03 UTC
at least, load site js first.
Comment 2 Melancholie 2009-09-18 13:57:57 UTC
Gadget scripts are meant here, they now get loaded before 
/w/index.php?title=-&action=raw&smaxage=0&gen=js&useskin=monobook
That's bad.
Comment 3 Brion Vibber 2009-09-18 22:34:46 UTC
Assigning to Michael on the assumption that this is related to the script loader changes. :)
Comment 4 Liangent 2009-09-19 05:00:55 UTC
not gadget scripts only, also wikibits.js etc.

we should move site js to the top.
Comment 5 Michael Dale 2009-09-19 18:42:51 UTC
hmm output flow is a bit of a mess trying to clean up ... we want sitejs above wikibits.js? I think we want sitejs right after core scripts no? 
Comment 6 Melancholie 2009-09-21 08:35:13 UTC
No, wikibits.js has to remain the very first.
Common.js, Monobook.js etc. heavily depend on stuff provided by wikibits.js ;-)

But the gadget scripts seem to have changed their position in source code, although they may depend on site scripts (now coming afterwards).
Comment 7 Melancholie 2009-09-21 08:36:13 UTC
1. Core
2. Site
3. Gadget
4. User
Comment 8 Melancholie 2009-09-21 09:10:34 UTC
Not quite sure, but shouldn't the line

<script type="text/javascript"
src="/w/extensions/FlaggedRevs/flaggedrevs.js?60"></script>

come directly after the core scripts? At the moment it comes last (</head>); maybe there is a reason for this, but if not it should be grouped with all the other core & extension scripts (like centralnotice.js e.g.).

Please see also bug 20690.
Comment 9 Michael Dale 2009-09-22 01:04:52 UTC
oky see commit 56746 moved to the
1. Core ( wikibits.js , jquery etc)
2. Site ( MediaWiki:Common.js, MediaWiki:Monobook.js, etc )
3. Extensions ( any extension that adds to mScripts or makes an outputPage->addScript* call at any time) 
4. User ( the user page User:$name$/monobook.js etc)

Script includes with scriptloader enabled is the following: 
1) core scripts
2) everything else in the above order that uses new Output page calls (addScriptFile, addScriptClass) 
3) things added with outputPage->addScript
Comment 10 Liangent 2009-09-22 01:35:56 UTC
make a link: r56746
Comment 11 Melancholie 2009-09-22 09:01:53 UTC
> 3. Extensions ( any extension that adds to mScripts or makes an
>    outputPage->addScript* call at any time) 

Hmm, wouldn't

1. Core
2. Extensions
3. Site
4. Gadget
5. User

be better (I considered "Extensions" being pretty much "Core" in comment #7, sorry)? Meaning extensions scripts coming second, _right_ after core scripts, instead after site scripts.

With site, gadget and user scripts the communities and users can use functions as well as use or adapt variables/arrays of core and extension scripts.

If extension scripts now will come after MediaWiki:Common.js and MediaWiki:Monobook.js, communities cannot customize vaiables e.g.
Comment 12 Michael Dale 2009-09-22 14:18:43 UTC
Comment #11 makes sense. But will require some modifications to the gadget & outputpage since Gadget is itself an extension and there is presently no way to call "add script after site but before user" from an extension :( .. We would have to add a few more "hooks". 

At any rate this is only an intermediary solution to configuration problem. We eventually want a system for the script-loader to package in configuration that is stored in a database and requested on a per Script-Class level (similar to how we package in the language msgs). This way we can have actual interfaces for customizing configuration instead of having to modify the JS files or modify mediaWiki pages with JS code). This should be part of the overall configuration flatfile to db rewrite. 

In the mean time .. we can structure development so the order does not matter so much... doing all configuration with inline-execution and inheriting the defaults onDomReady: see how editPage.js is structured in customizing the add-media-wizard: http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/js2/editPage.js 

another made up example for configuration handling : 

= core script editPage.js =
if(! wgConfigToolbar )
	wgConfigToolbar = {};

//the default configuration is short since the wikiEditor application supplies its own "defaults" 
wgDefaultToolBarSettings = { 'enabledModules':['sidepanel', 'help', 'tocnav'], 'otherDefaults: ['values'] };

js2AddOnloadHook( function() {
	//also see http://docs.jquery.com/Utilities/jQuery.extend
	wgConfigToolbar = $j.extend(true, wgDefaultToolBarSettings,  wgConfigToolbar);
	$j('#textEditBox').wikiEdit( wgConfigToolbar );
}
//the regardless of the order any script can set the configuration (although last scripts included wins where there are conflicts )

= script site js = 

if(! wgConfigToolbar)
	wgConfigToolbar = {};
wgConfigToolbar = $j.extend(wgConfigToolbar, { enabledModules: ['licenceHelper'] });

= script addEditWidget.js =

if(! wgConfigToolbar)
	wgConfigToolbar = {};

wgConfigToolbar = $j.extend(wgConfigToolbar, { 'enabledModules': ['myCustomTool'],  //array will be "merged" and default settings
	'customModules':{ 
		myCustomTool:function( wikiEditObj ){
			wikiEditObj.getTextSelection();
			//custom toolbar calls here
			wikiEditObj.insertBefore( 'my custom insert');
			//etc
		}
	}
}
//alternatively extension code can depend on core stuff being ready at js2AddOnloadHook time so: 
js2AddOnloadHook(function(){
	$j('#textEditBox').wikiEdit('addToolModule', :function( wikiEditObj ){
			wikiEditObj.getTextSelection();
			//custom toolbar calls here
			wikiEditObj.insertBefore( 'my custom insert');
			//etc
		}
	); //could also work. 
});

Comment 13 Melancholie 2009-09-22 14:58:48 UTC
Ah, okay. So it's currently (but not yet live):

1. Core
2. Site
3. Extensions (incl. Gadget (and maybe other 'group JS/CSS scripting' extensions out there)
4. User

That's ok for the moment, I think.
Like that, it at least seems to be like it was before (fixing this bug), I guess.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links