Merge "Remove cache use in setNewtalk, as nothing reads from that"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 28 Apr 2015 07:55:41 +0000 (07:55 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 28 Apr 2015 07:55:41 +0000 (07:55 +0000)
14 files changed:
api.php
img_auth.php
includes/Title.php
includes/api/ApiFeedRecentChanges.php
includes/changetags/ChangeTags.php
includes/content/ContentHandler.php
includes/jobqueue/JobQueueDB.php
includes/libs/objectcache/WANObjectCache.php
maintenance/benchmarks/benchmarkHooks.php
maintenance/language/checkLanguage.inc
maintenance/language/languages.inc
maintenance/refreshLinks.php
opensearch_desc.php
thumb.php

diff --git a/api.php b/api.php
index ea2f60a..7775158 100644 (file)
--- a/api.php
+++ b/api.php
@@ -75,7 +75,7 @@ try {
        $processor = new ApiMain( RequestContext::getMain(), $wgEnableWriteAPI );
 
        // Last chance hook before executing the API
-       wfRunHooks( 'ApiBeforeMain', array( &$processor ) );
+       Hooks::run( 'ApiBeforeMain', array( &$processor ) );
        if ( !$processor instanceof ApiMain ) {
                throw new MWException( 'ApiBeforeMain hook set $processor to a non-ApiMain class' );
        }
index f44cac0..22fd401 100644 (file)
@@ -151,7 +151,7 @@ function wfImageAuthMain() {
                // Run hook for extension authorization plugins
                /** @var $result array */
                $result = null;
-               if ( !wfRunHooks( 'ImgAuthBeforeStream', array( &$title, &$path, &$name, &$result ) ) ) {
+               if ( !Hooks::run( 'ImgAuthBeforeStream', array( &$title, &$path, &$name, &$result ) ) ) {
                        wfForbidden( $result[0], $result[1], array_slice( $result, 2 ) );
                        return;
                }
index b0df15f..7e2b39e 100644 (file)
@@ -940,7 +940,6 @@ class Title {
        /**
         * Get the page's content model id, see the CONTENT_MODEL_XXX constants.
         *
-        * @throws MWException
         * @param int $flags A bit field; may be Title::GAID_FOR_UPDATE to select for update
         * @return string Content model id
         */
@@ -955,10 +954,6 @@ class Title {
                        $this->mContentModel = ContentHandler::getDefaultModelFor( $this );
                }
 
-               if ( !$this->mContentModel ) {
-                       throw new MWException( 'Failed to determine content model!' );
-               }
-
                return $this->mContentModel;
        }
 
index d452bbd..d24112c 100644 (file)
@@ -66,9 +66,17 @@ class ApiFeedRecentChanges extends ApiBase {
 
                $formatter = $this->getFeedObject( $feedFormat, $specialClass );
 
-               // Everything is passed implicitly via $wgRequest… :(
-               // The row-getting functionality should maybe be factored out of ChangesListSpecialPage too…
+               // Parameters are passed via the request in the context… :(
+               $context = new DerivativeContext( $this );
+               $context->setRequest( new DerivativeRequest(
+                       $this->getRequest(),
+                       $this->params,
+                       $this->getRequest()->wasPosted()
+               ) );
+
+               // The row-getting functionality should be factored out of ChangesListSpecialPage too…
                $rc = new $specialClass();
+               $rc->setContext( $context );
                $rows = $rc->getRows();
 
                $feedItems = $rows ? ChangesFeed::buildItems( $rows ) : array();
index 43f957c..cf33484 100644 (file)
@@ -382,8 +382,9 @@ class ChangeTags {
         * @return Status
         * @since 1.25
         */
-       public static function addTagsAccompanyingChangeWithChecks( array $tags,
-               $rc_id, $rev_id, $log_id, $params, User $user ) {
+       public static function addTagsAccompanyingChangeWithChecks(
+               array $tags, $rc_id, $rev_id, $log_id, $params, User $user
+       ) {
 
                // are we allowed to do this?
                $result = self::canAddTagsAccompanyingChange( $tags, $user );
@@ -393,7 +394,7 @@ class ChangeTags {
                }
 
                // do it!
-               self::addTags( $tagsToAdd, $rc_id, $rev_id, $log_id, $params );
+               self::addTags( $tags, $rc_id, $rev_id, $log_id, $params );
 
                return Status::newGood( true );
        }
index 9c2435a..f8d0879 100644 (file)
@@ -629,7 +629,7 @@ abstract class ContentHandler {
 
                // hook: get difference engine
                $differenceEngine = null;
-               if ( !wfRunHooks( 'GetDifferenceEngine',
+               if ( !Hooks::run( 'GetDifferenceEngine',
                        array( $context, $old, $new, $refreshCache, $unhide, &$differenceEngine )
                ) ) {
                        return $differenceEngine;
index 320b1b1..b1b650b 100644 (file)
@@ -29,7 +29,6 @@
  */
 class JobQueueDB extends JobQueue {
        const CACHE_TTL_SHORT = 30; // integer; seconds to cache info without re-validating
-       const CACHE_TTL_LONG = 300; // integer; seconds to cache info that is kept up to date
        const MAX_AGE_PRUNE = 604800; // integer; seconds a job can live once claimed
        const MAX_JOB_RANDOM = 2147483647; // integer; 2^31 - 1, used for job_random
        const MAX_OFFSET = 255; // integer; maximum number of rows to skip
@@ -71,15 +70,6 @@ class JobQueueDB extends JobQueue {
         * @return bool
         */
        protected function doIsEmpty() {
-               $key = $this->getCacheKey( 'empty' );
-
-               $isEmpty = $this->cache->get( $key );
-               if ( $isEmpty === 'true' ) {
-                       return true;
-               } elseif ( $isEmpty === 'false' ) {
-                       return false;
-               }
-
                $dbr = $this->getSlaveDB();
                try {
                        $found = $dbr->selectField( // unclaimed job
@@ -88,7 +78,6 @@ class JobQueueDB extends JobQueue {
                } catch ( DBError $e ) {
                        $this->throwDBException( $e );
                }
-               $this->cache->add( $key, $found ? 'false' : 'true', self::CACHE_TTL_LONG );
 
                return !$found;
        }
@@ -272,8 +261,6 @@ class JobQueueDB extends JobQueue {
                        $dbw->commit( $method );
                }
 
-               $this->cache->set( $this->getCacheKey( 'empty' ), 'false', JobQueueDB::CACHE_TTL_LONG );
-
                return;
        }
 
@@ -282,10 +269,6 @@ class JobQueueDB extends JobQueue {
         * @return Job|bool
         */
        protected function doPop() {
-               if ( $this->cache->get( $this->getCacheKey( 'empty' ) ) === 'true' ) {
-                       return false; // queue is empty
-               }
-
                $dbw = $this->getMasterDB();
                try {
                        $dbw->commit( __METHOD__, 'flush' ); // flush existing transaction
@@ -308,7 +291,6 @@ class JobQueueDB extends JobQueue {
                                }
                                // Check if we found a row to reserve...
                                if ( !$row ) {
-                                       $this->cache->set( $this->getCacheKey( 'empty' ), 'true', self::CACHE_TTL_LONG );
                                        break; // nothing to do
                                }
                                JobQueue::incrStats( 'job-pop', $this->type );
@@ -569,7 +551,7 @@ class JobQueueDB extends JobQueue {
         * @return void
         */
        protected function doFlushCaches() {
-               foreach ( array( 'empty', 'size', 'acquiredcount' ) as $type ) {
+               foreach ( array( 'size', 'acquiredcount' ) as $type ) {
                        $this->cache->delete( $this->getCacheKey( $type ) );
                }
        }
@@ -680,8 +662,6 @@ class JobQueueDB extends JobQueue {
                                        $affected = $dbw->affectedRows();
                                        $count += $affected;
                                        JobQueue::incrStats( 'job-recycle', $this->type, $affected );
-                                       // The tasks recycled jobs or release delayed jobs into the queue
-                                       $this->cache->set( $this->getCacheKey( 'empty' ), 'false', self::CACHE_TTL_LONG );
                                        $this->aggr->notifyQueueNonEmpty( $this->wiki, $this->type );
                                }
                        }
index 6e5cad6..be62d1a 100755 (executable)
@@ -572,7 +572,7 @@ class WANObjectCache {
        /**
         * @param array $keys
         * @param string $prefix
-        * @return string
+        * @return string[]
         */
        protected static function prefixCacheKeys( array $keys, $prefix ) {
                $res = array();
index fb25b9d..1446871 100644 (file)
@@ -66,7 +66,7 @@ class BenchmarkHooks extends Benchmarker {
        private function benchHooks( $trials = 10 ) {
                $start = microtime( true );
                for ( $i = 0; $i < $trials; $i++ ) {
-                       wfRunHooks( 'Test' );
+                       Hooks::run( 'Test' );
                }
                $delta = microtime( true ) - $start;
                $pertrial = $delta / $trials;
index 990f258..0c3ea67 100644 (file)
@@ -339,7 +339,7 @@ ENDS;
 
                $blacklist = $checkBlacklist;
 
-               wfRunHooks( 'LocalisationChecksBlacklist', array( &$blacklist ) );
+               Hooks::run( 'LocalisationChecksBlacklist', array( &$blacklist ) );
 
                return $blacklist;
        }
index fb496cb..9affb9e 100644 (file)
@@ -63,7 +63,7 @@ class Languages {
         * files in the languages directory.
         */
        function __construct() {
-               wfRunHooks( 'LocalisationIgnoredOptionalMessages',
+               Hooks::run( 'LocalisationIgnoredOptionalMessages',
                        array( &$this->mIgnoredMessages, &$this->mOptionalMessages ) );
 
                $this->mLanguages = array_keys( Language::fetchLanguageNames( null, 'mwfile' ) );
index e1b6ac6..5d311ad 100644 (file)
@@ -83,7 +83,7 @@ class RefreshLinks extends Maintenance {
                }
 
                // Give extensions a chance to optimize settings
-               wfRunHooks( 'MaintenanceRefreshLinksInit', array( $this ) );
+               Hooks::run( 'MaintenanceRefreshLinksInit', array( $this ) );
 
                # Don't generate extension images (e.g. Timeline)
                $wgParser->clearTagHooks();
index 5e5e35d..0b56972 100644 (file)
@@ -94,7 +94,7 @@ foreach ( $wgOpenSearchTemplates as $type => $template ) {
 
 // Allow hooks to override the suggestion URL settings in a more
 // general way than overriding the whole search engine...
-wfRunHooks( 'OpenSearchUrls', array( &$urls ) );
+Hooks::run( 'OpenSearchUrls', array( &$urls ) );
 
 foreach ( $urls as $attribs ) {
        print Xml::element( 'Url', $attribs );
index 2ea3f07..2079a64 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -502,7 +502,7 @@ function wfExtractThumbParams( $file, $params ) {
        unset( $params['thumbName'] );
 
        // Do the hook first for older extensions that rely on it.
-       if ( !wfRunHooks( 'ExtractThumbParameters', array( $thumbname, &$params ) ) ) {
+       if ( !Hooks::run( 'ExtractThumbParameters', array( $thumbname, &$params ) ) ) {
                // Check hooks if parameters can be extracted
                // Hooks return false if they manage to *resolve* the parameters
                // This hook should be considered deprecated