Page MenuHomePhabricator

Title->getTemplateLinksTo(), getLinksTo() don't work properly due to usage of LinkCache::getSelectFields()
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • Identify an existing cargo table name
  • php extensions/Cargo/maintenance/cargoRecreateData.php --table <table name>

What happens?:
https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/refs/heads/master/includes/Title.php#3059

Due to page_namespace not being selected, it throws PHP WARN at
https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/refs/heads/master/includes/Title.php#3072
And empty Title object returned

[error] [674972808e8245805261935f] /api.php?action=cargorecreatedata&table=Familiars&template=Infobox-familiar&offset=0   PHP Notice: Undefined property: stdClass::$page_namespace
#0 /var/www/wiki/includes/Title.php(3158): MWExceptionHandler::handleError()
#1 /var/www/wiki/includes/Title.php(3179): Title->getLinksTo()
#2 /var/www/wiki/extensions/Cargo/includes/api/CargoRecreateDataAPI.php(42): Title->getTemplateLinksTo()
#3 /var/www/wiki/includes/api/ApiMain.php(1874): CargoRecreateDataAPI->execute()
#4 /var/www/wiki/includes/api/ApiMain.php(853): ApiMain->executeAction()
#5 /var/www/wiki/includes/api/ApiMain.php(824): ApiMain->executeActionWithErrorHandling()
#6 /var/www/wiki/api.php(90): ApiMain->execute()
#7 /var/www/wiki/api.php(45): wfApiMain()
#8 {main}

Due to this, Cargo data cannot be created as Title would always be empty

What should have happened instead?:
Title object should be properly setup and returned without any warning
Cargo data can be properly inserted and created

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:
https://github.com/wikimedia/mediawiki/tree/REL1_37
https://github.com/wikimedia/mediawiki-extensions-Cargo/tree/REL1_37

Suggested fix
Replace

LinkCache::getSelectFields(),

with

self::getSelectFields(),

Event Timeline

Assuming this task is about Cargo. Adding project tag so it can be found.

I believe this problem was fixed in Cargo v. 3.1. What version are you running?

Tried with
https://github.com/wikimedia/mediawiki-extensions-Cargo/tree/REL1_38
and
LinkCache::getSelectFields(),
in Title.php

	"name": "Cargo",
	"namemsg": "cargo-extensionname",
	"version": "3.1",

Exactly the same problem

PHP Notice:  Undefined property: stdClass::$page_namespace in /var/www/wiki/includes/Title.php on line 581
PHP Notice:  Undefined property: stdClass::$page_title in /var/www/wiki/includes/Title.php on line 581
Handling template that adds to this table:
Saving data for pages 1 to 0 that call this template...

Oh, I missed that part. Yes, you basically should never use the "REL_" branches for Cargo, or any of my extensions (except for maybe Replace Text). There is no guarantee that they will be compatible, or even work. Just use the latest code, which is still compatible with MW 1.32 and higher.

Hi,

Tested again with master, the problem seems to be with the wiki-core, not the Cargo itself

commit 4e75be97cf382e9c93a7edd67e5000024bed37b2 (HEAD -> master, origin/master, origin/HEAD)
Author: Translation updater bot <l10n-bot@translatewiki.net>
Date:   Wed Apr 6 08:26:36 2022 +0200
PHP Notice:  Undefined property: stdClass::$page_namespace in /var/www/wiki/includes/Title.php on line 581
PHP Notice:  Undefined property: stdClass::$page_title in /var/www/wiki/includes/Title.php on line 581

Hi,

Tested again with master, the problem seems to be with the wiki-core, not the Cargo itself

commit 4e75be97cf382e9c93a7edd67e5000024bed37b2 (HEAD -> master, origin/master, origin/HEAD)
Author: Translation updater bot <l10n-bot@translatewiki.net>
Date:   Wed Apr 6 08:26:36 2022 +0200
PHP Notice:  Undefined property: stdClass::$page_namespace in /var/www/wiki/includes/Title.php on line 581
PHP Notice:  Undefined property: stdClass::$page_title in /var/www/wiki/includes/Title.php on line 581

https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/master/includes/Title.php#581

This means the call to loadFromRow() is being passed a "row" which isn't actually a row of the page table. This suggests that Cargo is calling it with a wrong object.

Hi, sorry for the confusion

I have restored to REL1_37 for wiki-core (removed my change) and switched to Cargo REL1_38 and master, we will switch to use the latest master for now.

Both had worked correctly now without the PHP Notice.

The previous error were logged due to incorrect replace of

self::getSelectFields(),
`

with

LinkCache::getSelectFields(),

In the wrong location

Cargo REL1_37 remains incompatible with REL1_37 wiki core

@pandafox - just to clarify, does that mean there is no problem with the master version of Cargo?

Yes, there is no problem with wiki-core REL1_37 and master version of Cargo

pandafox claimed this task.

Resolved with wiki-core REL1_37 and master version of Cargo