Merge "Make Job::hasExecutionFlag() actually work"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 29 Mar 2019 22:54:58 +0000 (22:54 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 29 Mar 2019 22:54:58 +0000 (22:54 +0000)
1  2 
includes/jobqueue/Job.php

@@@ -41,7 -41,7 +41,7 @@@ abstract class Job implements IJobSpeci
        protected $title;
  
        /** @var bool Expensive jobs may set this to true */
 -      protected $removeDuplicates;
 +      protected $removeDuplicates = false;
  
        /** @var string Text for error that occurred last */
        protected $error;
         * Create the appropriate object to handle a specific job
         *
         * @param string $command Job command
 -       * @param Title $title Associated title
         * @param array $params Job parameters
         * @throws InvalidArgumentException
         * @return Job
         */
 -      public static function factory( $command, Title $title, $params = [] ) {
 +      public static function factory( $command, $params = [] ) {
                global $wgJobClasses;
  
 +              if ( $params instanceof Title ) {
 +                      // Backwards compatibility for old signature ($command, $title, $params)
 +                      $title = $params;
 +                      $params = func_num_args() >= 3 ? func_get_arg( 2 ) : [];
 +              } else {
 +                      // Subclasses can override getTitle() to return something more meaningful
 +                      $title = Title::makeTitle( NS_SPECIAL, 'Blankpage' );
 +              }
 +
                if ( isset( $wgJobClasses[$command] ) ) {
                        $handler = $wgJobClasses[$command];
  
  
                        if ( $job instanceof Job ) {
                                $job->command = $command;
 +
                                return $job;
                        } else {
 -                              throw new InvalidArgumentException( "Cannot instantiate job '$command': bad spec!" );
 +                              throw new InvalidArgumentException( "Could instantiate job '$command': bad spec!" );
                        }
                }
  
  
        /**
         * @param string $command
 -       * @param Title $title
 -       * @param array|bool $params Can not be === true
 +       * @param array $params
         */
 -      public function __construct( $command, $title, $params = false ) {
 +      public function __construct( $command, $params = [] ) {
 +              if ( $params instanceof Title ) {
 +                      // Backwards compatibility for old signature ($command, $title, $params)
 +                      $title = $params;
 +                      $params = func_num_args() >= 3 ? func_get_arg( 2 ) : [];
 +              } else {
 +                      // Subclasses can override getTitle() to return something more meaningful
 +                      $title = Title::makeTitle( NS_SPECIAL, 'Blankpage' );
 +              }
 +
                $this->command = $command;
                $this->title = $title;
                $this->params = is_array( $params ) ? $params : []; // sanity
 -
 -              // expensive jobs may set this to true
 -              $this->removeDuplicates = false;
 -
                if ( !isset( $this->params['requestId'] ) ) {
                        $this->params['requestId'] = WebRequest::getRequestId();
                }
         * @since 1.31
         */
        public function hasExecutionFlag( $flag ) {
-               return ( $this->executionFlags && $flag ) === $flag;
+               return ( $this->executionFlags & $flag ) === $flag;
        }
  
        /**