diff options
author | Aaron Schulz <aschulz@wikimedia.org> | 2016-09-08 01:38:26 -0700 |
---|---|---|
committer | Timo Tijhof <krinklemail@gmail.com> | 2016-09-08 14:46:18 -0700 |
commit | 6f8dc27ca2677c8222f1c45c63e7c3515004f4a5 (patch) | |
tree | 66b41badf7642841ed59e4e0e43f6cb494c762bb /includes/OutputPage.php | |
parent | a8c44660c1bcc5e83dc4bc2970cad535ccc7f92b (diff) | |
download | mediawikicore-6f8dc27ca2677c8222f1c45c63e7c3515004f4a5.tar.gz mediawikicore-6f8dc27ca2677c8222f1c45c63e7c3515004f4a5.zip |
Preload ResourceLoaderWikiModule::getTitleInfo in OutputPage
This avoids a separate query for each module.
Bug: T46362
Change-Id: Ie109a8776cbdcd5928cbb59351f2cf94088c0c95
Diffstat (limited to 'includes/OutputPage.php')
-rw-r--r-- | includes/OutputPage.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 6ae2a925f2c3..9b2d8da7af24 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -2679,16 +2679,29 @@ class OutputPage extends ContextSource { // Prepare exempt modules for buildExemptModules() $exemptGroups = [ 'site' => [], 'noscript' => [], 'private' => [], 'user' => [] ]; $exemptStates = []; - $moduleStyles = array_filter( $this->getModuleStyles( /*filter*/ true ), + $moduleStyles = $this->getModuleStyles( /*filter*/ true ); + + // Batch preload getTitleInfo for isKnownEmpty() calls below + $exemptModules = array_filter( $moduleStyles, + function ( $name ) use ( $rl, &$exemptGroups ) { + $module = $rl->getModule( $name ); + return $module && isset( $exemptGroups[ $module->getGroup() ] ); + } + ); + ResourceLoaderWikiModule::preloadTitleInfo( + $context, wfGetDB( DB_REPLICA ), $exemptModules ); + + // Filter out modules handled by buildExemptModules() + $moduleStyles = array_filter( $moduleStyles, function ( $name ) use ( $rl, $context, &$exemptGroups, &$exemptStates ) { $module = $rl->getModule( $name ); if ( $module ) { - $group = $module->getGroup(); if ( $name === 'user.styles' && $this->isUserCssPreview() ) { $exemptStates[$name] = 'ready'; // Special case in buildExemptModules() return false; } + $group = $module->getGroup(); if ( isset( $exemptGroups[$group] ) ) { $exemptStates[$name] = 'ready'; if ( !$module->isKnownEmpty( $context ) ) { |