Moving the "if ( $wgEnablePersistentLC )" from the caller to the callee
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 5 Jun 2004 04:44:45 +0000 (04:44 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 5 Jun 2004 04:44:45 +0000 (04:44 +0000)
includes/Article.php
includes/LinkCache.php

index 6ccc208..c9f7731 100644 (file)
@@ -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() );
        }
 }
 
index 8f41ccc..d2e1880 100644 (file)
@@ -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);
+               }
        }
 }
 ?>