+
+ # Load the newtalk status if it is unloaded (mNewtalk=-1)
+ if( $this->mNewtalk == -1 ) {
+ $this->mNewtalk = 0; # reset talk page status
+
+ # Check memcached separately for anons, who have no
+ # entire User object stored in there.
+ if( !$this->mId ) {
+ global $wgDBname, $wgMemc;
+ $key = "$wgDBname:newtalk:ip:{$this->mName}";
+ $newtalk = $wgMemc->get( $key );
+ if( is_integer( $newtalk ) ) {
+ $this->mNewtalk = $newtalk ? 1 : 0;
+ return (bool)$this->mNewtalk;
+ }
+ }
+
+ $dbr =& wfGetDB( DB_SLAVE );
+ $res = $dbr->select( 'watchlist',
+ array( 'wl_user' ),
+ array( 'wl_title' => $this->getTitleKey(),
+ 'wl_namespace' => NS_USER_TALK,
+ 'wl_user' => $this->mId,
+ 'wl_notificationtimestamp != 0' ),
+ 'User::getNewtalk' );
+ if( $dbr->numRows($res) > 0 ) {
+ $this->mNewtalk = 1;
+ }
+ $dbr->freeResult( $res );
+
+ if( !$this->mId ) {
+ $wgMemc->set( $key, $this->mNewtalk, time() ); // + 1800 );
+ }
+ }
+