Page MenuHomePhabricator

BadMethodCallException from line 98 of ApiCategoryTree.php: Call to a member function getDBkey() on a non-object
Closed, ResolvedPublic

Description

2018-08-16 10:53:22 [W3VXogpAIDoAAJvJwasAAABX] mw1346 enwiki 1.32.0-wmf.16 exception ERROR: [W3VXogpAIDoAAJvJwasAAABX] /w/api.php?action=categorytree&format=json&category=Monty_Burns%2527_Fleeing_Circus&options=%7B%22depth%22%3A+1%2C+%22mode%22%3A+%22pages%22%7D   BadMethodCallException from line 98 of /srv/mediawiki/php-1.32.0-wmf.16/extensions/CategoryTree/includes/ApiCategoryTree.php: Call to a member function getDBkey() on a non-object (null) {"exception_id":"W3VXogpAIDoAAJvJwasAAABX","exception_url":"/w/api.php?action=categorytree&format=json&category=Monty_Burns%2527_Fleeing_Circus&options=%7B%22depth%22%3A+1%2C+%22mode%22%3A+%22pages%22%7D","caught_by":"mwe_handler"} 
[Exception BadMethodCallException] (/srv/mediawiki/php-1.32.0-wmf.16/extensions/CategoryTree/includes/ApiCategoryTree.php:98) Call to a member function getDBkey() on a non-object (null)
  #0 /srv/mediawiki/php-1.32.0-wmf.16/extensions/CategoryTree/includes/ApiCategoryTree.php(42): ApiCategoryTree->getHTML(CategoryTree, NULL, integer, GlobalVarConfig)
  #1 /srv/mediawiki/php-1.32.0-wmf.16/includes/api/ApiMain.php(1579): ApiCategoryTree->execute()
  #2 /srv/mediawiki/php-1.32.0-wmf.16/includes/api/ApiMain.php(533): ApiMain->executeAction()
  #3 /srv/mediawiki/php-1.32.0-wmf.16/includes/api/ApiMain.php(504): ApiMain->executeActionWithErrorHandling()
  #4 /srv/mediawiki/php-1.32.0-wmf.16/api.php(83): ApiMain->execute()
  #5 /srv/mediawiki/w/api.php(3): include(string)
  #6 {main}

Event Timeline

Reedy created this task.Aug 16 2018, 1:49 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 16 2018, 1:49 PM
Reedy added a comment.Aug 16 2018, 1:51 PM
		$title = CategoryTree::makeTitle( $params['category'] );
<snip>
		$html = $this->getHTML( $ct, $title, $depth, $ctConfig );

CategoryTree::makeTitle can and does return null. Being passed straight to getHTML without any checking

thcipriani triaged this task as High priority.Aug 17 2018, 4:36 PM
thcipriani added a subscriber: thcipriani.

This is a very noisy message in the logs (23K messages over the past week, 2nd noisiest overall). Looks like @Reedy found the place for a null check. Would make a big difference to the look of logs to get this taken care of.

Change 453432 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/extensions/CategoryTree@master] Add api error 'invalidtitle' for invalid category param

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

Umherirrender added a subscriber: Umherirrender.

The query shows "%2527" in the data, which is double encoded ' and an invalid title in mediawiki.
The client has to use the non-encoded title and than only encode it once. (But I have no idea which one is the client)

I have added an api error which is more readable than the php fatal

Krinkle added subscribers: Anomie, Krinkle.

@Umherirrender already started a patch for this and @Anomie was reviewing it. Tagging to make sure it's on the radar.

Change 453432 merged by jenkins-bot:
[mediawiki/extensions/CategoryTree@master] Add api error 'invalidtitle' for invalid category param

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

Umherirrender closed this task as Resolved.Sep 6 2018, 4:08 PM
mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:09 PM