Page MenuHomePhabricator

PHP notice in LinkRecommendationUpdater::evaluateTitle() in PHP 7.4+
Closed, ResolvedPublicBUG REPORT

Description

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

On deployment-mwmaint02:

mwscript mysql.php --wiki=enwiki --write -- -e 'delete from growthexperiments_link_recommendations where gelr_revision=375365;'
PHP=php7.4 mwscript extensions/GrowthExperiments/maintenance/refreshLinkRecommendations.php --wiki=enwiki --page='Black-footed_cat' --verbose

It is a reverted revision with ct_params=null. Only revisions made after August 2020 have a JSON blob in ct_params.

What happens?:

2022-06-16 02:44:15 [424aa179bd90dc9e496c6ca0] deployment-mwmaint02 enwiki 1.39.0-alpha error ERROR: [424aa179bd90dc9e496c6ca0] [no req]   PHP Notice: Trying to access array offset on value of type null {"exception_url":"[no req]","reqId":"424aa179bd90dc9e496c6ca0","caught_by":"mwe_handler"} 
[Exception ErrorException] (/srv/mediawiki/php-master/extensions/GrowthExperiments/includes/NewcomerTasks/AddLink/LinkRecommendationUpdater.php:208) PHP Notice: Trying to access array offset on value of type null
  #0 /srv/mediawiki/php-master/extensions/GrowthExperiments/includes/NewcomerTasks/AddLink/LinkRecommendationUpdater.php(208): MWExceptionHandler::handleError(integer, string, string, integer, array)
  #1 /srv/mediawiki/php-master/extensions/GrowthExperiments/includes/NewcomerTasks/AddLink/LinkRecommendationUpdater.php(103): GrowthExperiments\NewcomerTasks\AddLink\LinkRecommendationUpdater->evaluateTitle(Title, MediaWiki\Revision\RevisionStoreRecord, boolean)
  #2 /srv/mediawiki/php-master/extensions/GrowthExperiments/maintenance/refreshLinkRecommendations.php(287): GrowthExperiments\NewcomerTasks\AddLink\LinkRecommendationUpdater->processCandidate(Title, boolean)
  #3 /srv/mediawiki/php-master/extensions/GrowthExperiments/maintenance/refreshLinkRecommendations.php(120): GrowthExperiments\Maintenance\RefreshLinkRecommendations->processCandidate(Title, boolean)
  #4 /srv/mediawiki/php-master/maintenance/includes/MaintenanceRunner.php(195): GrowthExperiments\Maintenance\RefreshLinkRecommendations->execute()
  #5 /srv/mediawiki/php-master/maintenance/doMaintenance.php(85): MediaWiki\Maintenance\MaintenanceRunner->run()
  #6 /srv/mediawiki/php-master/extensions/GrowthExperiments/maintenance/refreshLinkRecommendations.php(315): require_once(string)
  #7 /srv/mediawiki/multiversion/MWScript.php(123): require_once(string)
  #8 {main}

What should have happened instead?:

Refreshing link recommendations...
    checking candidate Black-footed_cat... success, updating index

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:

The code is (int)$tagData['newestRevertedRevId']. Before PHP 7.4 you can cast away unsetness and no notice is given. In PHP 7.4+ this is a notice when $tagData is null. I haven't found a PHP changelog or RFC, but 3v4l confirms that the change happened in 7.4.0.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 805927 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/extensions/GrowthExperiments@master] Fix PHP 7.4+ notice when ct_params is null

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

kostajh claimed this task.
kostajh subscribed.

Thanks @tstarling

Change 805927 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Fix PHP 7.4+ notice when ct_params is null

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