Merge "protect.js: Simplify by removing object ProtectionForm"
[lhc/web/wiklou.git] / includes / jobqueue / JobQueueRedis.php
index e9505bc..4d07a09 100644 (file)
@@ -203,7 +203,7 @@ class JobQueueRedis extends JobQueue {
                        }
                }
 
-               if ( !count( $items ) ) {
+               if ( $items === [] ) {
                        return; // nothing to do
                }
 
@@ -385,11 +385,11 @@ LUA;
         * @throws JobQueueError
         */
        protected function doAck( Job $job ) {
-               if ( !isset( $job->metadata['uuid'] ) ) {
+               $uuid = $job->getMetadata( 'uuid' );
+               if ( $uuid === null ) {
                        throw new UnexpectedValueException( "Job of type '{$job->getType()}' has no UUID." );
                }
 
-               $uuid = $job->metadata['uuid'];
                $conn = $this->getConnection();
                try {
                        static $script =
@@ -643,10 +643,11 @@ LUA;
                        }
                        $title = Title::makeTitle( $item['namespace'], $item['title'] );
                        $job = Job::factory( $item['type'], $title, $item['params'] );
-                       $job->metadata['uuid'] = $item['uuid'];
-                       $job->metadata['timestamp'] = $item['timestamp'];
+                       $job->setMetadata( 'uuid', $item['uuid'] );
+                       $job->setMetadata( 'timestamp', $item['timestamp'] );
                        // Add in attempt count for debugging at showJobs.php
-                       $job->metadata['attempts'] = $conn->hGet( $this->getQueueKey( 'h-attempts' ), $uid );
+                       $job->setMetadata( 'attempts',
+                               $conn->hGet( $this->getQueueKey( 'h-attempts' ), $uid ) );
 
                        return $job;
                } catch ( RedisException $e ) {
@@ -704,8 +705,8 @@ LUA;
        protected function getJobFromFields( array $fields ) {
                $title = Title::makeTitle( $fields['namespace'], $fields['title'] );
                $job = Job::factory( $fields['type'], $title, $fields['params'] );
-               $job->metadata['uuid'] = $fields['uuid'];
-               $job->metadata['timestamp'] = $fields['timestamp'];
+               $job->setMetadata( 'uuid', $fields['uuid'] );
+               $job->setMetadata( 'timestamp', $fields['timestamp'] );
 
                return $job;
        }
@@ -776,7 +777,7 @@ LUA;
         * @return string JSON
         */
        private function encodeQueueName() {
-               return json_encode( [ $this->type, $this->wiki ] );
+               return json_encode( [ $this->type, $this->domain ] );
        }
 
        /**
@@ -809,8 +810,9 @@ LUA;
         */
        private function getQueueKey( $prop, $type = null ) {
                $type = is_string( $type ) ? $type : $this->type;
-               list( $db, $prefix ) = wfSplitWikiID( $this->wiki );
-               $keyspace = $prefix ? "$db-$prefix" : $db;
+
+               // Use wiki ID for b/c
+               $keyspace = WikiMap::getWikiIdFromDbDomain( $this->domain );
 
                $parts = [ $keyspace, 'jobqueue', $type, $prop ];