From: Umherirrender Date: Fri, 5 Jul 2019 20:20:56 +0000 (+0200) Subject: Fix type hints in jobqueue related classes X-Git-Tag: 1.34.0-rc.0~1149^2 X-Git-Url: http://git.cyclocoop.org/wiki/%7B%7Bpath%7D%7Dmw-config/index.php?a=commitdiff_plain;h=cb82a52adfd838094b5114cb51b1ee3a3c14e109;p=lhc%2Fweb%2Fwiklou.git Fix type hints in jobqueue related classes JobQueueGroup is giving RunnableJob on pop(), so it should take the same type for ack() and deduplicateRootJob() JobQueue::ack alsready accept the interface Also change to RunnableJob in JobRunner to work with the type from the job queue Change-Id: I7b09586cff8affabe807ee16e80d04f5137dce45 --- diff --git a/includes/jobqueue/JobQueueGroup.php b/includes/jobqueue/JobQueueGroup.php index 2937d01238..756724e123 100644 --- a/includes/jobqueue/JobQueueGroup.php +++ b/includes/jobqueue/JobQueueGroup.php @@ -271,10 +271,10 @@ class JobQueueGroup { /** * Acknowledge that a job was completed * - * @param Job $job + * @param RunnableJob $job * @return void */ - public function ack( Job $job ) { + public function ack( RunnableJob $job ) { $this->get( $job->getType() )->ack( $job ); } @@ -282,10 +282,10 @@ class JobQueueGroup { * Register the "root job" of a given job into the queue for de-duplication. * This should only be called right *after* all the new jobs have been inserted. * - * @param Job $job + * @param RunnableJob $job * @return bool */ - public function deduplicateRootJob( Job $job ) { + public function deduplicateRootJob( RunnableJob $job ) { return $this->get( $job->getType() )->deduplicateRootJob( $job ); } diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php index 454f694c84..21d8c7e8af 100644 --- a/includes/jobqueue/JobRunner.php +++ b/includes/jobqueue/JobRunner.php @@ -23,7 +23,7 @@ use MediaWiki\MediaWikiServices; use MediaWiki\Logger\LoggerFactory; -use Liuggio\StatsdClient\Factory\StatsdDataFactory; +use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Wikimedia\ScopedCallback; @@ -265,13 +265,13 @@ class JobRunner implements LoggerAwareInterface { } /** - * @param Job $job + * @param RunnableJob $job * @param LBFactory $lbFactory - * @param StatsdDataFactory $stats + * @param StatsdDataFactoryInterface $stats * @param float $popTime * @return array Map of status/error/timeMs */ - private function executeJob( Job $job, LBFactory $lbFactory, $stats, $popTime ) { + private function executeJob( RunnableJob $job, LBFactory $lbFactory, $stats, $popTime ) { $jType = $job->getType(); $msg = $job->toString() . " STARTING"; $this->logger->debug( $msg, [ @@ -367,11 +367,11 @@ class JobRunner implements LoggerAwareInterface { } /** - * @param Job $job + * @param RunnableJob $job * @return int Seconds for this runner to avoid doing more jobs of this type * @see $wgJobBackoffThrottling */ - private function getBackoffTimeToWait( Job $job ) { + private function getBackoffTimeToWait( RunnableJob $job ) { $throttling = $this->config->get( 'JobBackoffThrottling' ); if ( !isset( $throttling[$job->getType()] ) || $job instanceof DuplicateJob ) { @@ -526,11 +526,11 @@ class JobRunner implements LoggerAwareInterface { * $wgJobSerialCommitThreshold for more. * * @param LBFactory $lbFactory - * @param Job $job + * @param RunnableJob $job * @param string $fnameTrxOwner * @throws DBError */ - private function commitMasterChanges( LBFactory $lbFactory, Job $job, $fnameTrxOwner ) { + private function commitMasterChanges( LBFactory $lbFactory, RunnableJob $job, $fnameTrxOwner ) { $syncThreshold = $this->config->get( 'JobSerialCommitThreshold' ); $time = false;