Page MenuHomePhabricator

$wgCategoryTreeMaxDepth broken (Incorrect merge method used in extension.json)
Closed, ResolvedPublic

Description

The $wgCategoryTreeMaxDepth configuration variable for the categorytree extension is using the wrong merge strategy (See https://www.mediawiki.org/wiki/Manual:Extension.json/Schema#config ) in extension.json

For example, if you specify in LocalSettings.php

$wgCategoryTreeMaxDepth = [0=> 5, 10 => 5, 20 => 5, 100 => 5];

It gets turned into (based on var_dump($wgCategoryTreeMaxDepth); ):

array(7) {
  [0]=>
  int(1)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(5)
  [4]=>
  int(5)
  [5]=>
  int(5)
  [6]=>
  int(5)
}

Which is totally different than what it should be, and as a result, the max depth is not actually changed since the array keys are messed up. Thus wikicode like <categorytree depth="3">Root_category_name</categorytree> only shows a depth of 1 and not 3. Instead we expect that if something like [ 0 => 7 ] is specified in LocalSettings.php, it overrides the 0 key, not that it gets added as a new key at the end of the array.

Prerequisites for this task:

  • You have installed MediaWiki locally
  • You are familiar with how to submit a patch to gerrit.

Your task is to modify the extension.json file in categorytree to use the array_plus merge method for the $wgCategoryTreeMaxDepth config variable. See https://www.mediawiki.org/wiki/Manual:Extension.json/Schema#config for documentation on the config fields of extension.json and how to specify merge methods (Keeping in mind that CategoryTree uses version 1 of the extension manifest format)

Once you have modified the file, test that setting $wgCategoryTreeMaxDepth in LocalSettings.php can correctly override the default setting. Then submit a patch to gerrit with an appropriate commit message

Event Timeline

Bawolff renamed this task from $wgCategoryTreeMaxDepth broken (Something wrong with how extension registration merges values?) to $wgCategoryTreeMaxDepth broken (Incorrect merge method used in extension.json).Dec 13 2019, 12:51 AM
Bawolff moved this task from Proposed tasks to Imported in GCI Site on the Google-Code-in-2019 board.

Change 558242 had a related patch set uploaded (by Pppery; owner: Pppery):
[mediawiki/extensions/CategoryTree@master] Fix merge strategy for $wgCategoryTreeMaxDepth

https://gerrit.wikimedia.org/r/558242

Change 558242 merged by jenkins-bot:
[mediawiki/extensions/CategoryTree@master] Fix merge strategy for $wgCategoryTreeMaxDepth

https://gerrit.wikimedia.org/r/558242