r111218 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111217‎ | r111218 | r111219 >
Date:23:41, 10 February 2012
Author:bsitu
Status:ok (Comments)
Tags:
Comment:
attempt to fix bug33989 - fix the mode parameter in api call
Modified paths:
  • /trunk/extensions/CategoryTree/CategoryTree.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CategoryTree/CategoryTree.php
@@ -170,7 +170,7 @@
171171 * Hook it up
172172 */
173173 function efCategoryTree() {
174 - global $wgUseAjax, $wgHooks, $wgOut;
 174+ global $wgUseAjax, $wgHooks, $wgOut, $wgRequest;
175175 global $wgCategoryTreeDefaultOptions, $wgCategoryTreeDefaultMode, $wgCategoryTreeOmitNamespace;
176176 global $wgCategoryTreeCategoryPageOptions, $wgCategoryTreeCategoryPageMode, $wgCategoryTreeAllowTag;
177177 global $wgCategoryTreeSidebarRoot, $wgCategoryTreeForceHeaders, $wgCategoryTreeHijackPageCategories;
@@ -204,8 +204,8 @@
205205 $wgCategoryTreeDefaultOptions['hideprefix'] = $wgCategoryTreeOmitNamespace;
206206 }
207207
208 - if ( !isset( $wgCategoryTreeCategoryPageOptions['mode'] ) || is_null( $wgCategoryTreeCategoryPageOptions['mode'] ) ) {
209 - $wgCategoryTreeCategoryPageOptions['mode'] = $wgCategoryTreeCategoryPageMode;
 208+ if ( !isset( $wgCategoryTreeCategoryPageOptions['mode'] ) || is_null( $wgCategoryTreeCategoryPageOptions['mode'] ) ) {
 209+ $wgCategoryTreeCategoryPageOptions['mode'] = ( $mode = $wgRequest->getVal( 'mode' ) ) ? CategoryTree::decodeMode( $mode ) : $wgCategoryTreeCategoryPageMode;
210210 }
211211
212212 if ( $wgCategoryTreeForceHeaders ) {
@@ -214,7 +214,7 @@
215215 $wgHooks['OutputPageParserOutput'][] = 'efCategoryTreeParserOutput';
216216 }
217217
218 - $wgHooks['ResourceLoaderGetConfigVars'][] = 'efCategoryTreeGetConfigVars';
 218+ $wgHooks['MakeGlobalVariablesScript'][] = 'efCategoryTreeGetConfigVars';
219219 }
220220
221221 /**

Sign-offs

UserFlagDate
Reedytested00:09, 11 February 2012

Follow-up revisions

RevisionCommit summaryAuthorDate
r111382MFT r111218, r111251reedy16:07, 13 February 2012
r113035MFT r110933, r111011, r111218, r112751, r112925, r112993reedy14:31, 5 March 2012
r113037MFT r110703, r110933, r111011, r111218, r112520, r112524, r112660, r112687, r...reedy14:59, 5 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98563Followup r98500, conversion of the Javascript to use jQuery fully. It also ma...johnduhart21:08, 30 September 2011

Comments

#Comment by RobLa-WMF (talk | contribs)   17:59, 11 February 2012

This is so full of win! I love it that such an insidious-seeming bug has a relatively small fix.

It might make things a little easier to understand to call:

$wgCategoryTreeCategoryPageOptions['mode'] = CategoryTree::decodeMode( $wgRequest->getVal( 'mode' ) );

...and then put the $wgCategoryTreeCategoryPageMode setting logic in CategoryTree::decodeMode function, since there's other logic in there which does default setting. That said, on casual inspection it's pretty hard to figure out the interplay of globals here, so I don't think that minor tweak would matter that much. Since this is a tested combination, seems great to call it good for 1.19.

Status & tagging log