Merge "jobqueue: remove entire unused JobQueueAggregator class hierarchy"
[lhc/web/wiklou.git] / includes / jobqueue / JobQueue.php
index 9f78fb8..8cfed3b 100644 (file)
@@ -29,7 +29,7 @@ use MediaWiki\MediaWikiServices;
  * @since 1.21
  */
 abstract class JobQueue {
-       /** @var string Wiki ID */
+       /** @var string DB domain ID */
        protected $domain;
        /** @var string Job type */
        protected $type;
@@ -51,7 +51,7 @@ abstract class JobQueue {
 
        /**
         * @param array $params
-        * @throws MWException
+        * @throws JobQueueError
         */
        protected function __construct( array $params ) {
                $this->domain = $params['domain'] ?? $params['wiki']; // b/c
@@ -64,7 +64,7 @@ abstract class JobQueue {
                        $this->order = $this->optimalOrder();
                }
                if ( !in_array( $this->order, $this->supportedOrders() ) ) {
-                       throw new MWException( __CLASS__ . " does not support '{$this->order}' order." );
+                       throw new JobQueueError( __CLASS__ . " does not support '{$this->order}' order." );
                }
                $this->dupCache = wfGetCache( CACHE_ANYTHING );
                $this->readOnlyReason = $params['readOnlyReason'] ?? false;
@@ -96,16 +96,16 @@ abstract class JobQueue {
         *
         * @param array $params
         * @return JobQueue
-        * @throws MWException
+        * @throws JobQueueError
         */
        final public static function factory( array $params ) {
                $class = $params['class'];
                if ( !class_exists( $class ) ) {
-                       throw new MWException( "Invalid job queue class '$class'." );
+                       throw new JobQueueError( "Invalid job queue class '$class'." );
                }
                $obj = new $class( $params );
                if ( !( $obj instanceof self ) ) {
-                       throw new MWException( "Class '$class' is not a " . __CLASS__ . " class." );
+                       throw new JobQueueError( "Class '$class' is not a " . __CLASS__ . " class." );
                }
 
                return $obj;
@@ -315,7 +315,7 @@ abstract class JobQueue {
         * @param IJobSpecification[] $jobs
         * @param int $flags Bitfield (supports JobQueue::QOS_ATOMIC)
         * @return void
-        * @throws MWException
+        * @throws JobQueueError
         */
        final public function batchPush( array $jobs, $flags = 0 ) {
                $this->assertNotReadOnly();
@@ -326,10 +326,10 @@ abstract class JobQueue {
 
                foreach ( $jobs as $job ) {
                        if ( $job->getType() !== $this->type ) {
-                               throw new MWException(
+                               throw new JobQueueError(
                                        "Got '{$job->getType()}' job; expected a '{$this->type}' job." );
                        } elseif ( $job->getReleaseTimestamp() && !$this->supportsDelayedJobs() ) {
-                               throw new MWException(
+                               throw new JobQueueError(
                                        "Got delayed '{$job->getType()}' job; delays are not supported." );
                        }
                }
@@ -355,7 +355,7 @@ abstract class JobQueue {
         * This requires $wgJobClasses to be set for the given job type.
         * Outside callers should use JobQueueGroup::pop() instead of this function.
         *
-        * @throws MWException
+        * @throws JobQueueError
         * @return Job|bool Returns false if there are no jobs
         */
        final public function pop() {
@@ -363,11 +363,11 @@ abstract class JobQueue {
 
                $this->assertNotReadOnly();
                if ( !WikiMap::isCurrentWikiDbDomain( $this->domain ) ) {
-                       throw new MWException(
+                       throw new JobQueueError(
                                "Cannot pop '{$this->type}' job off foreign '{$this->domain}' wiki queue." );
                } elseif ( !isset( $wgJobClasses[$this->type] ) ) {
                        // Do not pop jobs if there is no class for the queue type
-                       throw new MWException( "Unrecognized job type '{$this->type}'." );
+                       throw new JobQueueError( "Unrecognized job type '{$this->type}'." );
                }
 
                $job = $this->doPop();
@@ -399,12 +399,12 @@ abstract class JobQueue {
         *
         * @param Job $job
         * @return void
-        * @throws MWException
+        * @throws JobQueueError
         */
        final public function ack( Job $job ) {
                $this->assertNotReadOnly();
                if ( $job->getType() !== $this->type ) {
-                       throw new MWException( "Got '{$job->getType()}' job; expected '{$this->type}'." );
+                       throw new JobQueueError( "Got '{$job->getType()}' job; expected '{$this->type}'." );
                }
 
                $this->doAck( $job );
@@ -444,13 +444,13 @@ abstract class JobQueue {
         * This does nothing for certain queue classes.
         *
         * @param IJobSpecification $job
-        * @throws MWException
+        * @throws JobQueueError
         * @return bool
         */
        final public function deduplicateRootJob( IJobSpecification $job ) {
                $this->assertNotReadOnly();
                if ( $job->getType() !== $this->type ) {
-                       throw new MWException( "Got '{$job->getType()}' job; expected '{$this->type}'." );
+                       throw new JobQueueError( "Got '{$job->getType()}' job; expected '{$this->type}'." );
                }
 
                return $this->doDeduplicateRootJob( $job );
@@ -459,12 +459,12 @@ abstract class JobQueue {
        /**
         * @see JobQueue::deduplicateRootJob()
         * @param IJobSpecification $job
-        * @throws MWException
+        * @throws JobQueueError
         * @return bool
         */
        protected function doDeduplicateRootJob( IJobSpecification $job ) {
                if ( !$job->hasRootJobParams() ) {
-                       throw new MWException( "Cannot register root job; missing parameters." );
+                       throw new JobQueueError( "Cannot register root job; missing parameters." );
                }
                $params = $job->getRootJobParams();
 
@@ -487,12 +487,12 @@ abstract class JobQueue {
         * Check if the "root" job of a given job has been superseded by a newer one
         *
         * @param Job $job
-        * @throws MWException
+        * @throws JobQueueError
         * @return bool
         */
        final protected function isRootJobOldDuplicate( Job $job ) {
                if ( $job->getType() !== $this->type ) {
-                       throw new MWException( "Got '{$job->getType()}' job; expected '{$this->type}'." );
+                       throw new JobQueueError( "Got '{$job->getType()}' job; expected '{$this->type}'." );
                }
                $isDuplicate = $this->doIsRootJobOldDuplicate( $job );
 
@@ -547,10 +547,10 @@ abstract class JobQueue {
 
        /**
         * @see JobQueue::delete()
-        * @throws MWException
+        * @throws JobQueueError
         */
        protected function doDelete() {
-               throw new MWException( "This method is not implemented." );
+               throw new JobQueueError( "This method is not implemented." );
        }
 
        /**
@@ -651,7 +651,7 @@ abstract class JobQueue {
         *
         * @param array $types List of queues types
         * @return array|null (list of non-empty queue types) or null if unsupported
-        * @throws MWException
+        * @throws JobQueueError
         * @since 1.22
         */
        final public function getSiblingQueuesWithJobs( array $types ) {
@@ -674,7 +674,7 @@ abstract class JobQueue {
         *
         * @param array $types List of queues types
         * @return array|null (job type => whether queue is empty) or null if unsupported
-        * @throws MWException
+        * @throws JobQueueError
         * @since 1.22
         */
        final public function getSiblingQueueSizes( array $types ) {