r79885 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79884‎ | r79885 | r79886 >
Date:11:44, 9 January 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
Add a hook for registering variables in ResourceLoaderStartUpModule::getConfig() to complement MakeGlobalVariablesScript
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -1115,7 +1115,9 @@
11161116 $variableIDs: array of strings
11171117
11181118 'MakeGlobalVariablesScript': called right before Skin::makeVariablesScript
1119 -is executed
 1119+is executed. Ideally, this hook should only be used to add variables that
 1120+depend on the current page/request; static configuration should be added
 1121+through ResourceLoaderConfigVars instead.
11201122 &$vars: variable (or multiple variables) to be added into the output
11211123 of Skin::makeVariablesScript
11221124
@@ -1376,9 +1378,15 @@
13771379 &$obj: RawPage object
13781380 &$text: The text that's going to be the output
13791381
1380 -'RecentChange_save': called at the end of RecenChange::save()
 1382+'RecentChange_save': called at the end of RecentChange::save()
13811383 $recentChange: RecentChange object
13821384
 1385+'ResourceLoaderConfigVars': called at the end of
 1386+ResourceLoaderStartUpModule::getConfig(). Use this to export static
 1387+configuration variables to JavaScript. Things that depend on the current
 1388+page/request state must be added through MakeGlobalVariablesScript instead.
 1389+&$vars: array( variable name => value )
 1390+
13831391 'RevisionInsertComplete': called after a revision is inserted into the DB
13841392 &$revision: the Revision
13851393 $data: the data stored in old_text. The meaning depends on $flags: if external
Index: trunk/phase3/includes/resourceloader/ResourceLoaderStartUpModule.php
@@ -85,6 +85,8 @@
8686 $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
8787 }
8888
 89+ wfRunHooks( 'ResourceLoaderGetConfigVars', array( &$vars ) );
 90+
8991 return $vars;
9092 }
9193

Follow-up revisions

RevisionCommit summaryAuthorDate
r809751.17: MFT r79856, r79877, r79878, r79885, r79924, r79926, r79952catrope18:07, 25 January 2011

Comments

#Comment by Nikerabbit (talk | contribs)   13:13, 9 January 2011

Should this also have an entry in RELEASE-NOTES?

#Comment by Catrope (talk | contribs)   15:21, 9 January 2011

Maybe; I personally think it's a minor thing in RL-ifying an extension (and MakeGlobalVariablesScript continues to work, it's just that this hook's results are cached across pages), but you're right it should at least be documented on MW.org if not in R-N.

#Comment by Trevor Parscal (WMF) (talk | contribs)   00:55, 25 January 2011

I hope this does not get over-used, we need to also facilitate module-specific config vars that come with the modules.

Status & tagging log