Fixed Job constructor IDE notices about variable types
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 21 May 2015 18:02:35 +0000 (11:02 -0700)
committerUmherirrender <umherirrender_de.wp@web.de>
Sat, 30 May 2015 08:09:30 +0000 (08:09 +0000)
Change-Id: I4b4e4e38e8d416c3445c52ced311f5fbfcde868a

16 files changed:
includes/jobqueue/Job.php
includes/jobqueue/jobs/ActivityUpdateJob.php
includes/jobqueue/jobs/AssembleUploadChunksJob.php
includes/jobqueue/jobs/DoubleRedirectJob.php
includes/jobqueue/jobs/DuplicateJob.php
includes/jobqueue/jobs/EmaillingJob.php
includes/jobqueue/jobs/EnotifNotifyJob.php
includes/jobqueue/jobs/EnqueueJob.php
includes/jobqueue/jobs/HTMLCacheUpdateJob.php
includes/jobqueue/jobs/NullJob.php
includes/jobqueue/jobs/PublishStashedFileJob.php
includes/jobqueue/jobs/RecentChangesUpdateJob.php
includes/jobqueue/jobs/RefreshLinksJob.php
includes/jobqueue/jobs/ThumbnailRenderJob.php
includes/jobqueue/jobs/UploadFromUrlJob.php
includes/upload/UploadBase.php

index f8de0b5..87bd836 100644 (file)
@@ -32,7 +32,7 @@ abstract class Job implements IJobSpecification {
        /** @var string */
        public $command;
 
-       /** @var array|bool Array of job parameters or false if none */
+       /** @var array Array of job parameters */
        public $params;
 
        /** @var array Additional queue metadata */
@@ -58,11 +58,11 @@ abstract class Job implements IJobSpecification {
         *
         * @param string $command Job command
         * @param Title $title Associated title
-        * @param array|bool $params Job parameters
+        * @param array $params Job parameters
         * @throws MWException
         * @return Job
         */
-       public static function factory( $command, Title $title, $params = false ) {
+       public static function factory( $command, Title $title, $params = array() ) {
                global $wgJobClasses;
                if ( isset( $wgJobClasses[$command] ) ) {
                        $class = $wgJobClasses[$command];
@@ -80,7 +80,7 @@ abstract class Job implements IJobSpecification {
        public function __construct( $command, $title, $params = false ) {
                $this->command = $command;
                $this->title = $title;
-               $this->params = $params;
+               $this->params = is_array( $params ) ? $params : array(); // sanity
 
                // expensive jobs may set this to true
                $this->removeDuplicates = false;
index 495bda9..f146e6e 100644 (file)
@@ -27,7 +27,7 @@
  * @since 1.26
  */
 class ActivityUpdateJob extends Job {
-       function __construct( $title, $params ) {
+       function __construct( Title $title, array $params ) {
                parent::__construct( 'activityUpdateJob', $title, $params );
 
                if ( !isset( $params['type'] ) ) {
index b7f09e7..a1de77e 100644 (file)
@@ -27,7 +27,7 @@
  * @ingroup Upload
  */
 class AssembleUploadChunksJob extends Job {
-       public function __construct( $title, $params ) {
+       public function __construct( Title $title, array $params ) {
                parent::__construct( 'AssembleUploadChunks', $title, $params );
                $this->removeDuplicates = true;
        }
index 2561f2f..ab63896 100644 (file)
@@ -40,6 +40,16 @@ class DoubleRedirectJob extends Job {
        /** @var User */
        private static $user;
 
+       /**
+        * @param Title $title
+        * @param array $params
+        */
+       function __construct( Title $title, array $params ) {
+               parent::__construct( 'fixDoubleRedirect', $title, $params );
+               $this->reason = $params['reason'];
+               $this->redirTitle = Title::newFromText( $params['redirTitle'] );
+       }
+
        /**
         * Insert jobs into the job queue to fix redirects to the given title
         * @param string $reason The reason for the fix, see message
@@ -81,16 +91,6 @@ class DoubleRedirectJob extends Job {
                JobQueueGroup::singleton()->push( $jobs );
        }
 
-       /**
-        * @param Title $title
-        * @param array|bool $params
-        */
-       function __construct( $title, $params = false ) {
-               parent::__construct( 'fixDoubleRedirect', $title, $params );
-               $this->reason = $params['reason'];
-               $this->redirTitle = Title::newFromText( $params['redirTitle'] );
-       }
-
        /**
         * @return bool
         */
index c5e3a23..068d531 100644 (file)
@@ -33,7 +33,7 @@ final class DuplicateJob extends Job {
         * @param Title $title
         * @param array $params Job parameters
         */
-       function __construct( $title, $params ) {
+       function __construct( Title $title, array $params ) {
                parent::__construct( 'duplicate', $title, $params );
        }
 
index df8ae63..68e96fc 100644 (file)
@@ -28,7 +28,7 @@
  * @ingroup JobQueue
  */
 class EmaillingJob extends Job {
-       function __construct( $title, $params ) {
+       function __construct( Title $title = null, array $params ) {
                parent::__construct( 'sendMail', Title::newMainPage(), $params );
        }
 
index 1ed99a5..9a5c3c7 100644 (file)
@@ -27,7 +27,7 @@
  * @ingroup JobQueue
  */
 class EnotifNotifyJob extends Job {
-       function __construct( $title, $params ) {
+       function __construct( Title $title, array $params ) {
                parent::__construct( 'enotifNotify', $title, $params );
        }
 
index 4514e19..ca597ca 100755 (executable)
@@ -40,7 +40,7 @@ final class EnqueueJob extends Job {
         * @param Title $title
         * @param array $params Job parameters
         */
-       function __construct( $title, $params ) {
+       function __construct( Title $title, array $params ) {
                parent::__construct( 'enqueue', $title, $params );
        }
 
index e5e521c..a9010c2 100644 (file)
@@ -34,7 +34,7 @@
  * @ingroup JobQueue
  */
 class HTMLCacheUpdateJob extends Job {
-       function __construct( $title, $params = '' ) {
+       function __construct( Title $title, array $params ) {
                parent::__construct( 'htmlCacheUpdate', $title, $params );
                // Base backlink purge jobs can be de-duplicated
                $this->removeDuplicates = ( !isset( $params['range'] ) && !isset( $params['pages'] ) );
index f94d6eb..26d3c5c 100644 (file)
@@ -49,7 +49,7 @@ class NullJob extends Job {
         * @param Title $title
         * @param array $params Job parameters (lives, usleep)
         */
-       function __construct( $title, $params ) {
+       function __construct( Title $title, array $params ) {
                parent::__construct( 'null', $title, $params );
                if ( !isset( $this->params['lives'] ) ) {
                        $this->params['lives'] = 1;
index a922dd3..8a180ec 100644 (file)
@@ -29,7 +29,7 @@
  * @ingroup JobQueue
  */
 class PublishStashedFileJob extends Job {
-       public function __construct( $title, $params ) {
+       public function __construct( Title $title, array $params ) {
                parent::__construct( 'PublishStashedFile', $title, $params );
                $this->removeDuplicates = true;
        }
index cc04595..e86d914 100644 (file)
@@ -27,7 +27,7 @@
  * @since 1.25
  */
 class RecentChangesUpdateJob extends Job {
-       function __construct( $title, $params ) {
+       function __construct( Title $title, array $params ) {
                parent::__construct( 'recentChangesUpdate', $title, $params );
 
                if ( !isset( $params['type'] ) ) {
index 749913a..f706455 100644 (file)
@@ -39,7 +39,7 @@ class RefreshLinksJob extends Job {
 
        const CLOCK_FUDGE = 10;
 
-       function __construct( $title, $params = '' ) {
+       function __construct( Title $title, array $params ) {
                parent::__construct( 'refreshLinks', $title, $params );
                // A separate type is used just for cascade-protected backlinks
                if ( !empty( $this->params['prioritize'] ) ) {
index ab38138..a58fa8b 100644 (file)
@@ -27,7 +27,7 @@
  * @ingroup JobQueue
  */
 class ThumbnailRenderJob extends Job {
-       public function __construct( $title, $params ) {
+       public function __construct( Title $title, array $params ) {
                parent::__construct( 'ThumbnailRender', $title, $params );
        }
 
index d15fd02..a15d51e 100644 (file)
@@ -39,7 +39,7 @@ class UploadFromUrlJob extends Job {
        /** @var User */
        protected $user;
 
-       public function __construct( $title, $params ) {
+       public function __construct( Title $title, array $params ) {
                parent::__construct( 'uploadFromUrl', $title, $params );
        }
 
index df91588..d7c19ef 100644 (file)
@@ -746,11 +746,11 @@ abstract class UploadBase {
                $file = $this->getLocalFile();
 
                foreach ( $sizes as $size ) {
-                       if ( $file->isVectorized()
-                               || $file->getWidth() > $size ) {
-                                       $jobs[] = new ThumbnailRenderJob( $file->getTitle(), array(
-                                               'transformParams' => array( 'width' => $size ),
-                                       ) );
+                       if ( $file->isVectorized() || $file->getWidth() > $size ) {
+                               $jobs[] = new ThumbnailRenderJob(
+                                       $file->getTitle(),
+                                       array( 'transformParams' => array( 'width' => $size ) )
+                               );
                        }
                }