Merge "Fix CLI installer when --dbname is not specified on command line."
[lhc/web/wiklou.git] / includes / jobqueue / JobQueueDB.php
index d1e4a13..f10866e 100644 (file)
@@ -33,7 +33,7 @@ class JobQueueDB extends JobQueue {
        const MAX_JOB_RANDOM = 2147483647; // integer; 2^31 - 1, used for job_random
        const MAX_OFFSET = 255; // integer; maximum number of rows to skip
 
-       /** @var BagOStuff */
+       /** @var WANObjectCache */
        protected $cache;
 
        /** @var bool|string Name of an external DB cluster. False if not set */
@@ -48,13 +48,10 @@ class JobQueueDB extends JobQueue {
         * @param array $params
         */
        protected function __construct( array $params ) {
-               global $wgMemc;
-
                parent::__construct( $params );
 
                $this->cluster = isset( $params['cluster'] ) ? $params['cluster'] : false;
-               // Make sure that we don't use the SQL cache, which would be harmful
-               $this->cache = ( $wgMemc instanceof SqlBagOStuff ) ? new EmptyBagOStuff() : $wgMemc;
+               $this->cache = ObjectCache::getMainWANInstance();
        }
 
        protected function supportedOrders() {
@@ -144,15 +141,13 @@ class JobQueueDB extends JobQueue {
         * @throws MWException
         */
        protected function doGetAbandonedCount() {
-               global $wgMemc;
-
                if ( $this->claimTTL <= 0 ) {
                        return 0; // no acknowledgements
                }
 
                $key = $this->getCacheKey( 'abandonedcount' );
 
-               $count = $wgMemc->get( $key );
+               $count = $this->cache->get( $key );
                if ( is_int( $count ) ) {
                        return $count;
                }
@@ -170,14 +165,15 @@ class JobQueueDB extends JobQueue {
                } catch ( DBError $e ) {
                        $this->throwDBException( $e );
                }
-               $wgMemc->set( $key, $count, self::CACHE_TTL_SHORT );
+
+               $this->cache->set( $key, $count, self::CACHE_TTL_SHORT );
 
                return $count;
        }
 
        /**
         * @see JobQueue::doBatchPush()
-        * @param array $jobs
+        * @param IJobSpecification[] $jobs
         * @param int $flags
         * @throws DBError|Exception
         * @return void
@@ -198,7 +194,7 @@ class JobQueueDB extends JobQueue {
         * This function should *not* be called outside of JobQueueDB
         *
         * @param IDatabase $dbw
-        * @param array $jobs
+        * @param IJobSpecification[] $jobs
         * @param int $flags
         * @param string $method
         * @throws DBError
@@ -221,7 +217,7 @@ class JobQueueDB extends JobQueue {
                }
 
                if ( $flags & self::QOS_ATOMIC ) {
-                       $dbw->begin( $method ); // wrap all the job additions in one transaction
+                       $dbw->startAtomic( $method ); // wrap all the job additions in one transaction
                }
                try {
                        // Strip out any duplicate jobs that are already in the queue...
@@ -256,7 +252,7 @@ class JobQueueDB extends JobQueue {
                        throw $e;
                }
                if ( $flags & self::QOS_ATOMIC ) {
-                       $dbw->commit( $method );
+                       $dbw->endAtomic( $method );
                }
 
                return;
@@ -731,7 +727,7 @@ class JobQueueDB extends JobQueue {
                        // Additional job metadata
                        'job_id' => $dbw->nextSequenceValue( 'job_job_id_seq' ),
                        'job_timestamp' => $dbw->timestamp(),
-                       'job_sha1' => wfBaseConvert(
+                       'job_sha1' => Wikimedia\base_convert(
                                sha1( serialize( $job->getDeduplicationInfo() ) ),
                                16, 36, 31
                        ),