Last modified: 2010-09-24 22:19:06 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 T27049, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 25049 - Add hook for extensions to register into the resource loader
Add hook for extensions to register into the resource loader
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
1.17.x
All All
: Normal enhancement (vote)
: ---
Assigned To: Trevor Parscal
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-09-04 09:36 UTC by Trevor Parscal
Modified: 2010-09-24 22:19 UTC (History)
3 users (show)

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


Attachments

Description Trevor Parscal 2010-09-04 09:36:58 UTC
It'd be nice for extensions to register from a hook so they don't cause ResourceLoader.php and Resources.php to be loaded on every single request.
Comment 1 Trevor Parscal 2010-09-04 10:36:25 UTC
Something like...

// Allow extensions to register modules
wfRunHooks( 'ResourceLoaderBeforeRespond', $context );

...inside of ResourceLoader::respond().
Comment 2 Roan Kattouw 2010-09-13 20:11:47 UTC
(In reply to comment #1)
> Something like...
> 
> // Allow extensions to register modules
> wfRunHooks( 'ResourceLoaderBeforeRespond', $context );
> 
Pretty much yeah, except the second parameter is an array of parameters.

> ...inside of ResourceLoader::respond().
Because there are more ResourceLoader:: functions that use registrations, I'd prefer having a function called by all such entry points that then calls this hook once and only once.

In practical terms, something like

protected static function getHookRegistrations( $context ) {
    static $done = false;
    wfRunHooks( 'ResourceLoaderRegistrations', array( $context ) );
    $done = true;
}

Then in all functions using the registration data (including respond(), but also other functions reading from self::$modules), call this function.
Comment 3 Trevor Parscal 2010-09-22 21:57:36 UTC
This has been done for a while now. The hook is called ResourceLoaderRegisterModules.
Comment 4 Platonides 2010-09-22 22:38:08 UTC
Then why isn't it documented in doc/hooks.txt ?
Comment 5 Trevor Parscal 2010-09-24 22:19:06 UTC
It is as of r73686 - thanks for noticing.

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


Navigation
Links