Merge "Remove unused ApiStashEdit variable"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 18 Dec 2015 20:08:39 +0000 (20:08 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 18 Dec 2015 20:08:39 +0000 (20:08 +0000)
1  2 
includes/api/ApiStashEdit.php

@@@ -41,8 -41,6 +41,6 @@@ class ApiStashEdit extends ApiBase 
        const ERROR_UNCACHEABLE = 'uncacheable';
  
        public function execute() {
-               $cache = ObjectCache::getLocalClusterInstance();
                $user = $this->getUser();
                $params = $this->extractRequestParams();
  
        public static function checkCache( Title $title, Content $content, User $user ) {
                $cache = ObjectCache::getLocalClusterInstance();
                $logger = LoggerFactory::getInstance( 'StashEdit' );
 +              $stats = RequestContext::getMain()->getStats();
  
                $key = self::getStashKey( $title, $content, $user );
                $editInfo = $cache->get( $key );
                                $editInfo = $cache->get( $key );
                                $dbw->unlock( $key, __METHOD__ );
                        }
 -                      $sec = microtime( true ) - $start;
 -                      if ( $sec > .01 ) {
 -                              $logger->warning( "Waited $sec seconds on '$key'." );
 -                      }
 +
 +                      $timeMs = 1000 * max( 0, microtime( true ) - $start );
 +                      $stats->timing( 'editstash.lock-wait-time', $timeMs );
                }
  
                if ( !is_object( $editInfo ) || !$editInfo->output ) {
 +                      $stats->increment( 'editstash.cache-misses' );
                        $logger->debug( "No cache value for key '$key'." );
                        return false;
                }
  
                $time = wfTimestamp( TS_UNIX, $editInfo->output->getTimestamp() );
                if ( ( time() - $time ) <= 3 ) {
 +                      $stats->increment( 'editstash.cache-hits' );
                        $logger->debug( "Timestamp-based cache hit for key '$key'." );
                        return $editInfo; // assume nothing changed
                }
                        }
  
                        if ( $changed || $res->numRows() != $templateUses ) {
 +                              $stats->increment( 'editstash.cache-misses' );
                                $logger->info( "Stale cache for key '$key'; template changed." );
                                return false;
                        }
                        }
  
                        if ( $changed || $res->numRows() != count( $files ) ) {
 +                              $stats->increment( 'editstash.cache-misses' );
                                $logger->info( "Stale cache for key '$key'; file changed." );
                                return false;
                        }
                }
  
 +              $stats->increment( 'editstash.cache-hits' );
                $logger->debug( "Cache hit for key '$key'." );
  
                return $editInfo;