Page MenuHomePhabricator

TypeError in RefreshLinksJob.php: Argument 2 passed to RefreshLinksJob::__construct() must be of the type array, string given
Open, Needs TriagePublic

Description

On a Semantic Mediawiki enhanced wiki (SMW 2.5.6) every page gets an error like below, after upgrading to MW 1.31.0 from 1.27.4

TypeError from line 47 of /www/WIKIFARM131/includes/jobqueue/jobs/RefreshLinksJob.php: 
  Argument 2 passed to RefreshLinksJob::__construct() must be of the type array, string given, 
  called in /www/WIKIFARM131/includes/jobqueue/Job.php on line 83

Backtrace:

#0 /www/WIKIFARM131/includes/jobqueue/Job.php(83): RefreshLinksJob->__construct(Title, string)
#1 /www/WIKIFARM131/includes/jobqueue/JobQueueDB.php(303): Job::factory(string, Title, string, string)
#2 /www/WIKIFARM131/includes/jobqueue/JobQueue.php(372): JobQueueDB->doPop()
#3 /www/WIKIFARM131/includes/jobqueue/JobQueueGroup.php(263): JobQueue->pop()
#4 /www/WIKIFARM131/includes/jobqueue/JobRunner.php(167): JobQueueGroup->pop(integer, integer, array)
#5 /www/WIKIFARM131/includes/MediaWiki.php(1002): JobRunner->run(array)
#6 /www/WIKIFARM131/includes/MediaWiki.php(988): MediaWiki->triggerSyncJobs(integer, MediaWiki\Logger\LegacyLogger)
#7 /www/WIKIFARM131/includes/MediaWiki.php(912): MediaWiki->triggerJobs()
#8 /www/WIKIFARM131/includes/MediaWiki.php(727): MediaWiki->restInPeace(string, boolean)
#9 /www/WIKIFARM131/includes/MediaWiki.php(750): MediaWiki->{closure}()
#10 /www/WIKIFARM131/includes/MediaWiki.php(557): MediaWiki->doPostOutputShutdown(string)
#11 /www/WIKIFARM131/index.php(42): MediaWiki->run()
#12 {main}

The offending line at RefreshLinksJob.php(47)

function __construct( Title $title, array $params ) {

declares $params as array type.
In the call Job.php(83):
$job = new $handler( $title, $params );
variable $params was declared:
public static function factory( $command, Title $title, $params = [] ) {
Somehow $params is unexpectedly called with a string value, the result of:
$job = Job::factory( $row->job_cmd, $title, self::extractBlob( $row->job_params ), $row->job_id );

I got rid of the error message by changing Job.php(83) to:
$job = new $handler( $title, array( $params ) );

I guess the problem is not solved this way...

Event Timeline

Aklapper renamed this task from TypeError from line 47 of ./includes/jobqueue/jobs/RefreshLinksJob.php: to TypeError in RefreshLinksJob.php: Argument 2 passed to RefreshLinksJob::__construct() must be of the type array, string given.Jul 19 2019, 11:45 PM

This issue occurs on my newly installed MW-1.31.3 (update from 1.23). I wrote a report in https://www.mediawiki.org/wiki/Topic:V4egqqyigg9mpsjt prior to finding this location. Sorry for double-posting!

My problem was solved with a huge amount of help by MarkAHershberger in https://www.mediawiki.org/wiki/Topic:V4egqqyigg9mpsjt
I do not think that my issue applies in general.

You should always clear any pending jobs (by running runJobs.php) before performing an upgrade

Thanks for the comment, Ciencia_Al_Poder! In fact, I should have known but I must have overlooked the respective section in Manual:Upgrading. -- Silencing now in favor of the original issue.