From 03745055d37f78fd9392382b2649f50d8a95b5c6 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 5 Jun 2004 04:44:45 +0000 Subject: [PATCH] Moving the "if ( $wgEnablePersistentLC )" from the caller to the callee --- includes/Article.php | 16 ++++------------ includes/LinkCache.php | 28 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 6ccc2084c1..c9f773198e 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1641,7 +1641,7 @@ class Article { # This is called on page move and undelete, as well as edit /* static */ function onArticleCreate($title_obj){ - global $wgEnablePersistentLC, $wgUseSquid, $wgDeferredUpdateList; + global $wgUseSquid, $wgDeferredUpdateList; $titles = $title_obj->getBrokenLinksTo(); @@ -1656,23 +1656,15 @@ class Article { } # Clear persistent link cache - if ( $wgEnablePersistentLC ) { - LinkCache::linksccClearBrokenLinksTo( $title_obj->getPrefixedDBkey() ); - } + LinkCache::linksccClearBrokenLinksTo( $title_obj->getPrefixedDBkey() ); } /* static */ function onArticleDelete($title_obj){ - global $wgEnablePersistentLC; - if ( $wgEnablePersistentLC ) { - LinkCache::linksccClearLinksTo( $title_obj->getArticleID() ); - } + LinkCache::linksccClearLinksTo( $title_obj->getArticleID() ); } /* static */ function onArticleEdit($title_obj){ - global $wgEnablePersistentLC; - if ( $wgEnablePersistentLC ) { - LinkCache::linksccClearPage( $title_obj->getArticleID() ); - } + LinkCache::linksccClearPage( $title_obj->getArticleID() ); } } diff --git a/includes/LinkCache.php b/includes/LinkCache.php index 8f41cccf7e..d2e188003c 100644 --- a/includes/LinkCache.php +++ b/includes/LinkCache.php @@ -171,6 +171,7 @@ class LinkCache { if ( $wgEnablePersistentLC ) { if( $this->fillFromLinkscc( $id ) ){ + wfProfileOut( $fname ); return; } } @@ -313,23 +314,32 @@ class LinkCache { # $pid is a page id /* static */ function linksccClearLinksTo( $pid ){ - $pid = intval( $pid ); - wfQuery("DELETE linkscc FROM linkscc,links ". - "WHERE lcc_pageid=links.l_from AND l_to={$pid}", DB_WRITE); - wfQuery("DELETE FROM linkscc WHERE lcc_pageid='{$pid}'", DB_WRITE); + global $wgEnablePersistentLC; + if ( $wgEnablePersistentLC ) { + $pid = intval( $pid ); + wfQuery("DELETE linkscc FROM linkscc,links ". + "WHERE lcc_pageid=links.l_from AND l_to={$pid}", DB_WRITE); + wfQuery("DELETE FROM linkscc WHERE lcc_pageid='{$pid}'", DB_WRITE); + } } # $title is a prefixed db title, for example like Title->getPrefixedDBkey() returns. /* static */ function linksccClearBrokenLinksTo( $title ){ - $title = wfStrencode( $title ); - wfQuery("DELETE linkscc FROM linkscc,brokenlinks ". - "WHERE lcc_pageid=bl_from AND bl_to='{$title}'", DB_WRITE); + global $wgEnablePersistentLC; + if ( $wgEnablePersistentLC ) { + $title = wfStrencode( $title ); + wfQuery("DELETE linkscc FROM linkscc,brokenlinks ". + "WHERE lcc_pageid=bl_from AND bl_to='{$title}'", DB_WRITE); + } } # $pid is a page id /* static */ function linksccClearPage( $pid ){ - $pid = intval( $pid ); - wfQuery("DELETE FROM linkscc WHERE lcc_pageid='{$pid}'", DB_WRITE); + global $wgEnablePersistentLC; + if ( $wgEnablePersistentLC ) { + $pid = intval( $pid ); + wfQuery("DELETE FROM linkscc WHERE lcc_pageid='{$pid}'", DB_WRITE); + } } } ?> -- 2.20.1