From 9283e7395ef03ae4de4d0daa8479920b851b7333 Mon Sep 17 00:00:00 2001 From: parent5446 Date: Fri, 27 Jul 2012 16:46:55 -0400 Subject: [PATCH] (bug 36776) Changing User::getNewtalk to use $wgDisableAnonTalk. 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 --- includes/User.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/includes/User.php b/includes/User.php index ca8ce8f15a..583b587234 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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 ); -- 2.20.1