Merge "Converted User touched key to using the WAN cache"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 11 May 2015 16:52:48 +0000 (16:52 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 11 May 2015 16:52:48 +0000 (16:52 +0000)
1  2 
includes/User.php

diff --combined includes/User.php
@@@ -2252,6 -2252,8 +2252,6 @@@ class User implements IDBAccessObject 
         *   page. Ignored if null or !$val.
         */
        public function setNewtalk( $val, $curRev = null ) {
 -              global $wgMemc;
 -
                if ( wfReadOnly() ) {
                        return;
                }
                        $changed = $this->deleteNewtalk( $field, $id );
                }
  
 -              if ( $this->isAnon() ) {
 -                      // Anons have a separate memcached space, since
 -                      // user records aren't kept for them.
 -                      $key = wfMemcKey( 'newtalk', 'ip', $id );
 -                      $wgMemc->set( $key, $val ? 1 : 0, 1800 );
 -              }
                if ( $changed ) {
                        $this->invalidateCache();
                }
         * @since 1.25
         */
        public function touch() {
-               global $wgMemc;
                $this->load();
  
                if ( $this->mId ) {
+                       $this->mQuickTouched = $this->newTouchedTimestamp();
+                       $cache = ObjectCache::getMainWANInstance();
                        $key = wfMemcKey( 'user-quicktouched', 'id', $this->mId );
-                       $timestamp = $this->newTouchedTimestamp();
-                       $wgMemc->set( $key, $timestamp );
-                       $this->mQuickTouched = $timestamp;
+                       $cache->touchCheckKey( $key );
                }
        }
  
         * @return string TS_MW Timestamp
         */
        public function getTouched() {
-               global $wgMemc;
                $this->load();
  
                if ( $this->mId ) {
                        if ( $this->mQuickTouched === null ) {
+                               $cache = ObjectCache::getMainWANInstance();
                                $key = wfMemcKey( 'user-quicktouched', 'id', $this->mId );
-                               $timestamp = $wgMemc->get( $key );
+                               $timestamp = $cache->getCheckKeyTime( $key );
                                if ( $timestamp ) {
-                                       $this->mQuickTouched = $timestamp;
+                                       $this->mQuickTouched = wfTimestamp( TS_MW, $timestamp );
                                } else {
                                        # Set the timestamp to get HTTP 304 cache hits
                                        $this->touch();
                        $force = 'force';
                }
  
 -              $this->getWatchedItem( $title )->resetNotificationTimestamp( $force, $oldid );
 +              $this->getWatchedItem( $title )->resetNotificationTimestamp(
 +                      $force, $oldid, WatchedItem::DEFERRED
 +              );
        }
  
        /**