Fix type hints in jobqueue related classes
authorUmherirrender <umherirrender_de.wp@web.de>
Fri, 5 Jul 2019 20:20:56 +0000 (22:20 +0200)
committerUmherirrender <umherirrender_de.wp@web.de>
Fri, 5 Jul 2019 20:20:56 +0000 (22:20 +0200)
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

includes/jobqueue/JobQueueGroup.php
includes/jobqueue/JobRunner.php

index 2937d01..756724e 100644 (file)
@@ -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 );
        }
 
index 454f694..21d8c7e 100644 (file)
@@ -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;