jenkins-bot has submitted this change and it was merged.

Change subject: Use hooks instead of $wgOut when $wgCategoryTreeForceHeaders is 
set
......................................................................


Use hooks instead of $wgOut when $wgCategoryTreeForceHeaders is set

Previously, $wgOut was used when $wgCategoryTreeForceHeaders was set and
a hook was used when it was not.
This change makes sure there is always a hook used with an OutputPage
instance. It fixes bug 57651.

Using $wgOut the rebuildFileCache.php maintenance script would generate
pages without JavaScript and CSS for CategoryTree when
$wgCategoryTreeForceHeaders was set (for example, when the sidebar was
in use).

Other uses of $wgOut in the CategoryTree extension seem to be less of an
issue because when there is a CategoryTree on a page, those pages seem
to be excluded from caching. (But fixing those would be nice
nonetheless: it may prevent other bugs in the future).

Bug: 57651
Change-Id: I0ee66d38755e255c5597db7a237a176039025fae
---
M CategoryTree.php
1 file changed, 17 insertions(+), 3 deletions(-)

Approvals:
  Brian Wolff: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CategoryTree.php b/CategoryTree.php
index 7da350d..c76c659 100644
--- a/CategoryTree.php
+++ b/CategoryTree.php
@@ -170,7 +170,7 @@
  * Hook it up
  */
 function efCategoryTree() {
-       global $wgUseAjax, $wgHooks, $wgOut, $wgRequest;
+       global $wgUseAjax, $wgHooks, $wgRequest;
        global $wgCategoryTreeDefaultOptions, $wgCategoryTreeDefaultMode, 
$wgCategoryTreeOmitNamespace;
        global $wgCategoryTreeCategoryPageOptions, 
$wgCategoryTreeCategoryPageMode, $wgCategoryTreeAllowTag;
        global $wgCategoryTreeSidebarRoot, $wgCategoryTreeForceHeaders, 
$wgCategoryTreeHijackPageCategories;
@@ -209,7 +209,7 @@
        }
 
        if ( $wgCategoryTreeForceHeaders ) {
-               CategoryTree::setHeaders( $wgOut );
+               $wgHooks['BeforePageDisplay'][] = 'efCategoryTreeAddHeaders';
        } else {
                $wgHooks['OutputPageParserOutput'][] = 
'efCategoryTreeParserOutput';
        }
@@ -375,7 +375,8 @@
 }
 
 /**
- * Hook callback that injects messages and things into the <head> tag
+ * Hook callback that injects messages and things into the <head> tag,
+ * if needed in the current page.
  * Does nothing if $parserOutput->mCategoryTreeTag is not set
  * @param $outputPage OutputPage
  * @param $parserOutput ParserOutput
@@ -389,6 +390,19 @@
 }
 
 /**
+ * BeforePageDisplay hook. This hook is set when $wgCategoryTreeForceHeaders
+ * is set.
+ * Otherwise similar to efCategoryTreeParserOutput.
+ * @param $out OutputPage
+ * @param $skin Skin
+ * @return bool
+ */
+function efCategoryTreeAddHeaders( OutputPage $out, Skin $skin )  {
+       CategoryTree::setHeaders( $out );
+       return true;
+}
+
+/**
  * ArticleFromTitle hook, override category page handling
  *
  * @param $title Title

-- 
To view, visit https://gerrit.wikimedia.org/r/99649
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0ee66d38755e255c5597db7a237a176039025fae
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/CategoryTree
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Gerrit Patch Uploader <[email protected]>
Gerrit-Reviewer: Leaves in Motion <[email protected]>
Gerrit-Reviewer: Njw <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to