(bug 36776) Changing User::getNewtalk to use $wgDisableAnonTalk.
authorparent5446 <tylerromeo@gmail.com>
Fri, 27 Jul 2012 20:46:55 +0000 (16:46 -0400)
committerparent5446 <tylerromeo@gmail.com>
Fri, 27 Jul 2012 20:46:55 +0000 (16:46 -0400)
Previously, $wgDisableAnonTalk was only used as a visual
hack in includes/Linker.php. Now, if the variable is set,
no queries will be made to user_newtalk at all.

Change-Id: Id5521abbec7f05f2de7230f9f0316176abc7f215
Signed-off-by: parent5446 <tylerromeo@gmail.com>
includes/User.php

index ca8ce8f..583b587 100644 (file)
@@ -1764,16 +1764,22 @@ class User {
                        # Check memcached separately for anons, who have no
                        # entire User object stored in there.
                        if( !$this->mId ) {
-                               global $wgMemc;
-                               $key = wfMemcKey( 'newtalk', 'ip', $this->getName() );
-                               $newtalk = $wgMemc->get( $key );
-                               if( strval( $newtalk ) !== '' ) {
-                                       $this->mNewtalk = (bool)$newtalk;
+                               global $wgDisableAnonTalk;
+                               if( $wgDisableAnonTalk ) {
+                                       // Anon newtalk disabled by configuration.
+                                       $this->mNewtalk = false;
                                } else {
-                                       // Since we are caching this, make sure it is up to date by getting it
-                                       // from the master
-                                       $this->mNewtalk = $this->checkNewtalk( 'user_ip', $this->getName(), true );
-                                       $wgMemc->set( $key, (int)$this->mNewtalk, 1800 );
+                                       global $wgMemc;
+                                       $key = wfMemcKey( 'newtalk', 'ip', $this->getName() );
+                                       $newtalk = $wgMemc->get( $key );
+                                       if( strval( $newtalk ) !== '' ) {
+                                               $this->mNewtalk = (bool)$newtalk;
+                                       } else {
+                                               // Since we are caching this, make sure it is up to date by getting it
+                                               // from the master
+                                               $this->mNewtalk = $this->checkNewtalk( 'user_ip', $this->getName(), true );
+                                               $wgMemc->set( $key, (int)$this->mNewtalk, 1800 );
+                                       }
                                }
                        } else {
                                $this->mNewtalk = $this->checkNewtalk( 'user_id', $this->mId );