Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/126746

Change subject: Finish removing boolean return values from JobQueue code
......................................................................

Finish removing boolean return values from JobQueue code

This is a possible follow-up for patch
Ia706ac0122a7dd7f418e2dc2d3bd36e9a0252c25.

Please feel free to upload new patch sets on top of this one or do
your own. Please tell me if I should abandone this one.

Change-Id: I19fe58a939706d3f7594d937e0bcad6d97c52a50
---
M includes/jobqueue/JobQueue.php
M includes/jobqueue/JobQueueDB.php
M includes/jobqueue/JobQueueFederated.php
M includes/jobqueue/JobQueueGroup.php
M includes/jobqueue/JobQueueRedis.php
M maintenance/copyJobQueue.php
6 files changed, 16 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/46/126746/1

diff --git a/includes/jobqueue/JobQueue.php b/includes/jobqueue/JobQueue.php
index 9b13aea..0dd784d 100644
--- a/includes/jobqueue/JobQueue.php
+++ b/includes/jobqueue/JobQueue.php
@@ -323,7 +323,7 @@
         */
        final public function batchPush( array $jobs, $flags = 0 ) {
                if ( !count( $jobs ) ) {
-                       return true; // nothing to do
+                       return; // nothing to do
                }
 
                foreach ( $jobs as $job ) {
diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php
index 5f1ca14..6bde89f 100644
--- a/includes/jobqueue/JobQueueDB.php
+++ b/includes/jobqueue/JobQueueDB.php
@@ -191,7 +191,7 @@
         * @param array $jobs
         * @param $flags
         * @throws DBError|Exception
-        * @return bool
+        * @return void
         */
        protected function doBatchPush( array $jobs, $flags ) {
                $dbw = $this->getMasterDB();
@@ -203,8 +203,6 @@
                                $that->doBatchPushInternal( $dbw, $jobs, 
$flags, $method );
                        }
                );
-
-               return true;
        }
 
        /**
@@ -215,11 +213,11 @@
         * @param int $flags
         * @param string $method
         * @throws DBError
-        * @return bool
+        * @return void
         */
        public function doBatchPushInternal( IDatabase $dbw, array $jobs, 
$flags, $method ) {
                if ( !count( $jobs ) ) {
-                       return true;
+                       return;
                }
 
                $rowSet = array(); // (sha1 => job) map for jobs that are 
de-duplicated
@@ -277,7 +275,7 @@
 
                $this->cache->set( $this->getCacheKey( 'empty' ), 'false', 
JobQueueDB::CACHE_TTL_LONG );
 
-               return true;
+               return;
        }
 
        /**
diff --git a/includes/jobqueue/JobQueueFederated.php 
b/includes/jobqueue/JobQueueFederated.php
index f2599ae..6be9876 100644
--- a/includes/jobqueue/JobQueueFederated.php
+++ b/includes/jobqueue/JobQueueFederated.php
@@ -224,8 +224,6 @@
                        throw new JobQueueError(
                                "Could not insert job(s), 
{$this->maxPartitionsTry} partitions tried." );
                }
-
-               return true;
        }
 
        /**
diff --git a/includes/jobqueue/JobQueueGroup.php 
b/includes/jobqueue/JobQueueGroup.php
index b1dfe14..4dd0614 100644
--- a/includes/jobqueue/JobQueueGroup.php
+++ b/includes/jobqueue/JobQueueGroup.php
@@ -106,12 +106,12 @@
         *
         * @param Job|array $jobs A single Job or a list of Jobs
         * @throws MWException
-        * @return bool
+        * @return void
         */
        public function push( $jobs ) {
                $jobs = is_array( $jobs ) ? $jobs : array( $jobs );
                if ( !count( $jobs ) ) {
-                       return true;
+                       return;
                }
 
                $jobsByType = array(); // (job type => list of jobs)
@@ -123,13 +123,9 @@
                        }
                }
 
-               $ok = true;
                foreach ( $jobsByType as $type => $jobs ) {
-                       if ( $this->get( $type )->push( $jobs ) ) {
-                               
JobQueueAggregator::singleton()->notifyQueueNonEmpty( $this->wiki, $type );
-                       } else {
-                               $ok = false;
-                       }
+                       $this->get( $type )->push( $jobs );
+                       JobQueueAggregator::singleton()->notifyQueueNonEmpty( 
$this->wiki, $type );
                }
 
                if ( $this->cache->has( 'queues-ready', 'list' ) ) {
@@ -138,8 +134,6 @@
                                $this->cache->clear( 'queues-ready' );
                        }
                }
-
-               return $ok;
        }
 
        /**
diff --git a/includes/jobqueue/JobQueueRedis.php 
b/includes/jobqueue/JobQueueRedis.php
index 135a61d..bd8db9b 100644
--- a/includes/jobqueue/JobQueueRedis.php
+++ b/includes/jobqueue/JobQueueRedis.php
@@ -195,7 +195,7 @@
         * @see JobQueue::doBatchPush()
         * @param array $jobs
         * @param $flags
-        * @return bool
+        * @return void
         * @throws JobQueueError
         */
        protected function doBatchPush( array $jobs, $flags ) {
@@ -211,7 +211,7 @@
                }
 
                if ( !count( $items ) ) {
-                       return true; // nothing to do
+                       return; // nothing to do
                }
 
                $conn = $this->getConnection();
@@ -235,7 +235,7 @@
                        if ( $failed > 0 ) {
                                wfDebugLog( 'JobQueueRedis', "Could not insert 
{$failed} {$this->type} job(s)." );
 
-                               return false;
+                               throw new RedisException( "Could not insert 
{$failed} {$this->type} job(s)." );
                        }
                        JobQueue::incrStats( 'job-insert', $this->type, count( 
$items ), $this->wiki );
                        JobQueue::incrStats( 'job-insert-duplicate', 
$this->type,
@@ -243,8 +243,6 @@
                } catch ( RedisException $e ) {
                        $this->throwRedisException( $conn, $e );
                }
-
-               return true;
        }
 
        /**
diff --git a/maintenance/copyJobQueue.php b/maintenance/copyJobQueue.php
index e833115..c5a7827 100644
--- a/maintenance/copyJobQueue.php
+++ b/maintenance/copyJobQueue.php
@@ -78,17 +78,15 @@
                        ++$total;
                        $batch[] = $job;
                        if ( count( $batch ) >= $this->mBatchSize ) {
-                               if ( $dst->push( $batch ) ) {
-                                       $totalOK += count( $batch );
-                               }
+                               $dst->push( $batch );
+                               $totalOK += count( $batch );
                                $batch = array();
                                $dst->waitForBackups();
                        }
                }
                if ( count( $batch ) ) {
-                       if ( $dst->push( $batch ) ) {
-                               $totalOK += count( $batch );
-                       }
+                       $dst->push( $batch );
+                       $totalOK += count( $batch );
                        $dst->waitForBackups();
                }
                return array( $total, $totalOK );

-- 
To view, visit https://gerrit.wikimedia.org/r/126746
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I19fe58a939706d3f7594d937e0bcad6d97c52a50
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to