Page MenuHomePhabricator

TypeError: array_flip(): Argument #1 ($array) must be of type array, null given
Closed, ResolvedPublic1 Estimated Story PointsBUG REPORT

Description

While trying to seed some image suggestions locally I stumbled on this error.

Steps to replicate the issue (include links if applicable):

➜  w git:(master) php maintenance/run.php ./extensions/CirrusSearch/maintenance/UpdateWeightedTags.php --tagType 'recommendation.image' --page Nanocomposite --verbose

What happens?:
An error is thrown, the script cannot be used without tagName option as it was doing prior to rECIRd7c02d73ad0637c7dd4f5f06abc6b4ee542b39e5

[865069a1605512609323e693] [no req]   TypeError: array_flip(): Argument #1 ($array) must be of type array, null given
Backtrace:
from /Users/sergio/src/mediawiki/w/extensions/CirrusSearch/maintenance/UpdateWeightedTags.php(70)
#0 /Users/sergio/src/mediawiki/w/extensions/CirrusSearch/maintenance/UpdateWeightedTags.php(70): array_flip(null)
#1 /Users/sergio/src/mediawiki/w/maintenance/includes/MaintenanceRunner.php(694): CirrusSearch\Maintenance\UpdateWeightedTags->execute()
#2 /Users/sergio/src/mediawiki/w/maintenance/run.php(51): MediaWiki\Maintenance\MaintenanceRunner->run()
#3 {main}

What should have happened instead?:

The script should run without a tagName option?

Event Timeline

Looking at the code it seems that despite tagName being optional I don't see how it can work without it... we should probably make it explicitly required. For you I suspect the correct call args should be:
--tagType 'recommendation.image' --tagName 'exists' --page Nanocomposite --verbose

dcausse renamed this task from TypeError when running UpdateWeightedTags to TypeError: array_flip(): Argument #1 ($array) must be of type array, null given.Apr 4 2025, 12:25 PM
dcausse added a subscriber: Reedy.
Gehel set the point value for this task to 1.Apr 7 2025, 3:38 PM

Change #1136330 had a related patch set uploaded (by DCausse; author: DCausse):

[mediawiki/extensions/CirrusSearch@master] UpdateWeightedTags: make tagName mandatory

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

Change #1136330 merged by jenkins-bot:

[mediawiki/extensions/CirrusSearch@master] UpdateWeightedTags: make tagName mandatory

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