Last modified: 2014-04-06 21:28:35 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 T59651, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 57651 - JavaScript is not loaded with the 'rebuildFileCache.php' maintenance script
JavaScript is not loaded with the 'rebuildFileCache.php' maintenance script
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
CategoryTree (Other open bugs)
REL1_22-branch
All All
: High normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-27 12:52 UTC by 11fallingleaves
Modified: 2014-04-06 21:28 UTC (History)
3 users (show)

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


Attachments

Description 11fallingleaves 2013-11-27 12:52:23 UTC
When running

    php maintenance/rebuildFileCache.php

script headers are not added to the resulting cached pages, disabling the functionality to expand categories.

I have tested this with these settings:

    $wgCategoryTreeSidebarRoot = 'Articles';
    $wgCategoryTreeSidebarOptions['mode'] = 'pages';

This enables $wgCategoryTreeForceHeaders.

The problem lies in the use of $wgOut (which is deprecated). When $wgCategoryTreeForceHeaders is enabled, the problem is here, in CategoryTree.php:

	if ( $wgCategoryTreeForceHeaders ) {
		CategoryTree::setHeaders( $wgOut );
	} else {
		$wgHooks['OutputPageParserOutput'][] = 'efCategoryTreeParserOutput';
	}

This is only run once on initialization. So, when caching pages with rebuildFileCache.php, subsequent pages do not get the headers they need (I have not verified whether the first one gets them, but I don't think that's very important).

I have made some changes that make rebuildFileCache work again when $wgCategoryTreeForceHeaders is enabled (by not using $wgOut), but ideally $wgOut should not be used anywhere anymore preventing such problems. I can post the changes if needed, but they only really fix half of the problem.
Comment 1 Andre Klapper 2013-11-27 13:10:20 UTC
Thanks for taking the time to report this!

(In reply to comment #0)
> I can post the changes if needed, but they only 
> really fix half of the problem.

I guess it could still be welcome as a starter.
Comment 2 11fallingleaves 2013-11-27 13:36:47 UTC
Here is the git diff:

diff --git a/CategoryTree.php b/CategoryTree.php
index 5d0bbdf..24c1025 100644
--- a/CategoryTree.php
+++ b/CategoryTree.php
@@ -209,11 +209,7 @@ function efCategoryTree() {
 		$wgCategoryTreeCategoryPageOptions['mode'] = ( $mode = $wgRequest->getVal( 'mode' ) ) ? CategoryTree::decodeMode( $mode ) : $wgCategoryTreeCategoryPageMode;
 	}
 
-	if ( $wgCategoryTreeForceHeaders ) {
-		CategoryTree::setHeaders( $wgOut );
-	} else {
-		$wgHooks['OutputPageParserOutput'][] = 'efCategoryTreeParserOutput';
-	}
+	$wgHooks['OutputPageParserOutput'][] = 'efCategoryTreeParserOutput';
 
 	$wgHooks['MakeGlobalVariablesScript'][] = 'efCategoryTreeGetConfigVars';
 }
@@ -383,7 +379,8 @@ function efCategoryTreeParserHook( $cat, $argv, $parser = null, $allowMissing =
  * @return bool
  */
 function efCategoryTreeParserOutput( $outputPage, $parserOutput )  {
-	if ( !empty( $parserOutput->mCategoryTreeTag ) ) {
+	global $wgCategoryTreeForceHeaders;
+	if ( $wgCategoryTreeForceHeaders || !empty( $parserOutput->mCategoryTreeTag ) ) {
 		CategoryTree::setHeaders( $outputPage );
 	}
 	return true;
Comment 3 11fallingleaves 2013-12-06 14:36:50 UTC
I uploaded the patch:
https://gerrit.wikimedia.org/r/#/c/99649/

I believe this should fix most of it, maybe all, but $wgOut is used in a few other places. I think that part is in need of a refactor / small rewrite. I do not have enough familiarity with CategoryTree to do that in a good way.
Comment 4 Andre Klapper 2013-12-09 15:21:01 UTC
Thanks! Setting PATCH_TO_REVIEW status (though patch needs rework)
Comment 5 11fallingleaves 2013-12-10 05:11:21 UTC
Wait - don't merge this patch. It's broken.

I realized this patch does not work on pages that are not parsed pages, like Special:Preferences.
(Strangely, it does work on Special:RecentChanges, I suppose there's some parsing going on there.)
So, it needs a different hook that's called on *every* page, not just parsed pages.
Comment 6 Gerrit Notification Bot 2013-12-12 01:19:48 UTC
Change 99649 had a related patch set uploaded by Leaves in Motion:
Use hooks instead of $wgOut when $wgCategoryTreeForceHeaders is set

https://gerrit.wikimedia.org/r/99649
Comment 7 Gerrit Notification Bot 2014-04-06 21:26:55 UTC
Change 99649 merged by jenkins-bot:
Use hooks instead of $wgOut when $wgCategoryTreeForceHeaders is set

https://gerrit.wikimedia.org/r/99649
Comment 8 Bawolff (Brian Wolff) 2014-04-06 21:28:35 UTC
There's a lot of other things very very outdated in the way CategoryTree handles js that could also use with fixing. Anyways, patch merged, marking bug as fixed.

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


Navigation
Links