From 4c9a4b75d361a22f933a578a0905cd99fbf584e1 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Mon, 14 Apr 2008 16:41:54 +0000 Subject: [PATCH] Tweaks: remove call to empty function LinkCache::clearLink() and don't check if $id is an integer as it is set to null just before that. --- includes/LinkCache.php | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/includes/LinkCache.php b/includes/LinkCache.php index 79bb7446c4..f2099c8b59 100644 --- a/includes/LinkCache.php +++ b/includes/LinkCache.php @@ -91,7 +91,6 @@ class LinkCache { public function clearBadLink( $title ) { unset( $this->mBadLinks[$title] ); - $this->clearLink( $title ); } /* obsolete, for old $wgLinkCacheMemcached stuff */ @@ -125,14 +124,14 @@ class LinkCache { * @return integer */ public function addLinkObj( &$nt, $len = -1, $redirect = NULL ) { - global $wgAntiLockFlags; + global $wgAntiLockFlags, $wgProfiler; + $title = $nt->getPrefixedDBkey(); if ( $this->isBadLink( $title ) ) { return 0; } $id = $this->getGoodLinkID( $title ); if ( 0 != $id ) { return $id; } $fname = 'LinkCache::addLinkObj'; - global $wgProfiler; if ( isset( $wgProfiler ) ) { $fname .= ' (' . $wgProfiler->getCurrentSection() . ')'; } @@ -146,32 +145,29 @@ class LinkCache { wfProfileOut( $fname ); return 0; } + # Some fields heavily used for linking... - $id = NULL; - - if( !is_integer( $id ) ) { - if ( $this->mForUpdate ) { - $db = wfGetDB( DB_MASTER ); - if ( !( $wgAntiLockFlags & ALF_NO_LINK_LOCK ) ) { - $options = array( 'FOR UPDATE' ); - } else { - $options = array(); - } + if ( $this->mForUpdate ) { + $db = wfGetDB( DB_MASTER ); + if ( !( $wgAntiLockFlags & ALF_NO_LINK_LOCK ) ) { + $options = array( 'FOR UPDATE' ); } else { - $db = wfGetDB( DB_SLAVE ); $options = array(); } - - $s = $db->selectRow( 'page', - array( 'page_id', 'page_len', 'page_is_redirect' ), - array( 'page_namespace' => $ns, 'page_title' => $t ), - $fname, $options ); - # Set fields... - $id = $s ? $s->page_id : 0; - $len = $s ? $s->page_len : -1; - $redirect = $s ? $s->page_is_redirect : 0; + } else { + $db = wfGetDB( DB_SLAVE ); + $options = array(); } + $s = $db->selectRow( 'page', + array( 'page_id', 'page_len', 'page_is_redirect' ), + array( 'page_namespace' => $ns, 'page_title' => $t ), + $fname, $options ); + # Set fields... + $id = $s ? $s->page_id : 0; + $len = $s ? $s->page_len : -1; + $redirect = $s ? $s->page_is_redirect : 0; + if( 0 == $id ) { $this->addBadLinkObj( $nt ); } else { -- 2.20.1