Merge "content: Recognise .json as JsonContent in User and MediaWiki namespace"
[lhc/web/wiklou.git] / includes / User.php
index 1936efd..bf0326a 100644 (file)
@@ -1229,7 +1229,7 @@ class User implements IDBAccessObject {
                        self::selectFields(),
                        array( 'user_id' => $this->mId ),
                        __METHOD__,
-                       ( $flags & self::READ_LOCKING == self::READ_LOCKING )
+                       ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING )
                                ? array( 'LOCK IN SHARE MODE' )
                                : array()
                );
@@ -2251,8 +2251,6 @@ class User implements IDBAccessObject {
         *   page. Ignored if null or !$val.
         */
        public function setNewtalk( $val, $curRev = null ) {
-               global $wgMemc;
-
                if ( wfReadOnly() ) {
                        return;
                }
@@ -2274,12 +2272,6 @@ class User implements IDBAccessObject {
                        $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();
                }
@@ -2309,11 +2301,10 @@ class User implements IDBAccessObject {
         * Called implicitly from invalidateCache() and saveSettings().
         */
        public function clearSharedCache() {
-               $this->load();
-               if ( $this->mId ) {
-                       $cache = ObjectCache::getMainWANInstance();
-
-                       $cache->delete( wfMemcKey( 'user', 'id', $this->mId ) );
+               $id = $this->getId();
+               if ( $id ) {
+                       $key = wfMemcKey( 'user', 'id', $id );
+                       ObjectCache::getMainWANInstance()->delete( $key );
                }
        }
 
@@ -2340,15 +2331,11 @@ class User implements IDBAccessObject {
         * @since 1.25
         */
        public function touch() {
-               global $wgMemc;
-
-               $this->load();
-
-               if ( $this->mId ) {
-                       $key = wfMemcKey( 'user-quicktouched', 'id', $this->mId );
-                       $timestamp = $this->newTouchedTimestamp();
-                       $wgMemc->set( $key, $timestamp );
-                       $this->mQuickTouched = $timestamp;
+               $id = $this->getId();
+               if ( $id ) {
+                       $key = wfMemcKey( 'user-quicktouched', 'id', $id );
+                       ObjectCache::getMainWANInstance()->touchCheckKey( $key );
+                       $this->mQuickTouched = null;
                }
        }
 
@@ -2366,16 +2353,16 @@ class User implements IDBAccessObject {
         * @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();
@@ -2393,7 +2380,7 @@ class User implements IDBAccessObject {
         * @return string TS_MW Timestamp
         * @since 1.26
         */
-       protected function getDBTouched() {
+       public function getDBTouched() {
                $this->load();
 
                return $this->mTouched;
@@ -3454,7 +3441,9 @@ class User implements IDBAccessObject {
                        $force = 'force';
                }
 
-               $this->getWatchedItem( $title )->resetNotificationTimestamp( $force, $oldid );
+               $this->getWatchedItem( $title )->resetNotificationTimestamp(
+                       $force, $oldid, WatchedItem::DEFERRED
+               );
        }
 
        /**