mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-27 09:43:06 +00:00
Remove check for shouldForceHeaders()
The CategoryTree::setHeaders() method adds modules to OutputPage. It does not matter if setHeaders() gets called several times. The previous code tried to avoid to call setHeaders() several times. If wgCategoryTreeForceHeaders is set then the modules get loaded by the hooks "BeforePageDisplay" or "BeforePageDisplayMobile" on every page. In this case duplicate calls of setHeaders() are (partly) avoided by not calling setHeaders() on other hooks. This change removes this micro optimization and loads the modules unconditionally if a category tree is added on a hook. shouldForceHeaders() is now inlined. Change-Id: Ic9219575a714886b4edd446efde2a330dff4dee6
This commit is contained in:
parent
20f433c17c
commit
4bc230093f
|
@ -36,9 +36,7 @@ class CategoryTreeCategoryViewer extends CategoryViewer {
|
|||
*/
|
||||
private function getCategoryTree() {
|
||||
if ( !isset( $this->categorytree ) ) {
|
||||
if ( !Hooks::shouldForceHeaders() ) {
|
||||
CategoryTree::setHeaders( $this->getOutput() );
|
||||
}
|
||||
CategoryTree::setHeaders( $this->getOutput() );
|
||||
|
||||
$options = $this->getConfig()->get( 'CategoryTreeCategoryPageOptions' );
|
||||
|
||||
|
|
|
@ -111,9 +111,7 @@ class CategoryTreePage extends SpecialPage {
|
|||
$this->executeInputForm();
|
||||
|
||||
if ( $this->target !== '' && $this->target !== null ) {
|
||||
if ( !Hooks::shouldForceHeaders() ) {
|
||||
CategoryTree::setHeaders( $output );
|
||||
}
|
||||
CategoryTree::setHeaders( $output );
|
||||
|
||||
$title = CategoryTree::makeTitle( $this->target );
|
||||
|
||||
|
|
|
@ -83,15 +83,6 @@ class Hooks implements
|
|||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal For use by CategoryTreeCategoryViewer and CategoryTreePage only!
|
||||
* @return bool
|
||||
*/
|
||||
public static function shouldForceHeaders() {
|
||||
global $wgCategoryTreeForceHeaders;
|
||||
return $wgCategoryTreeForceHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Parser $parser
|
||||
*/
|
||||
|
@ -233,10 +224,6 @@ class Hooks implements
|
|||
* @param ParserOutput $parserOutput
|
||||
*/
|
||||
public function onOutputPageParserOutput( $outputPage, $parserOutput ): void {
|
||||
if ( self::shouldForceHeaders() ) {
|
||||
// Skip, we've already set the headers unconditionally
|
||||
return;
|
||||
}
|
||||
if ( $parserOutput->getExtensionData( self::EXTENSION_DATA_FLAG ) ) {
|
||||
CategoryTree::setHeaders( $outputPage );
|
||||
}
|
||||
|
@ -260,10 +247,10 @@ class Hooks implements
|
|||
* @param OutputPage $out
|
||||
*/
|
||||
public static function addHeaders( OutputPage $out ) {
|
||||
if ( !self::shouldForceHeaders() ) {
|
||||
return;
|
||||
global $wgCategoryTreeForceHeaders;
|
||||
if ( $wgCategoryTreeForceHeaders ) {
|
||||
CategoryTree::setHeaders( $out );
|
||||
}
|
||||
CategoryTree::setHeaders( $out );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue