Some changes to the link tables. They now all use a key on cur_id for the *_from...
[lhc/web/wiklou.git] / includes / LinkCache.php
index f4c50c0..93721af 100644 (file)
@@ -148,17 +148,26 @@ class LinkCache {
                $fname = "LinkCache::preFill";
                wfProfileIn( $fname );
                # Note -- $fromtitle is a Title *object*
-               $dbkeyfrom = wfStrencode( $fromtitle->getPrefixedDBKey() );
 
+               $this->suspend();
+               $id = $fromtitle->getArticleID();
+               $this->resume();
+               
+               if( $id == 0 ) {
+                       wfDebug( "$fname - got id 0 for title '" . $fromtitle->getPrefixedDBkey() . "'\n" );
+                       wfProfileOut( $fname );
+                       return;
+               }
+               
                if ( $wgEnablePersistentLC ) {
-                       if( $this->fillFromLinkscc( $dbkeyfrom ) ){
+                       if( $this->fillFromLinkscc( $id ) ){
                                return;
                        }
                }
 
                $sql = "SELECT cur_id,cur_namespace,cur_title
                        FROM cur,links
-                       WHERE cur_id=l_to AND l_from='{$dbkeyfrom}'";
+                       WHERE cur_id=l_to AND l_from=$id";
                $res = wfQuery( $sql, DB_READ, $fname );
                while( $s = wfFetchObject( $res ) ) {
                        $this->addGoodLink( $s->cur_id,
@@ -166,16 +175,6 @@ class LinkCache {
                                );
                }
                
-               $this->suspend();
-               $id = $fromtitle->getArticleID();
-               $this->resume();
-               
-               if( $id == 0 ) {
-                       wfDebug( "$fname - got id 0 for title '" . $fromtitle->getPrefixedDBkey() . "'\n" );
-                       wfProfileOut( $fname );
-                       return;
-               }
-               
                $sql = "SELECT bl_to
                        FROM brokenlinks
                        WHERE bl_from='{$id}'";
@@ -264,8 +263,9 @@ class LinkCache {
                $this->mImageLinks = array();
        }
 
-       /* private */ function fillFromLinkscc( $dbkeyfrom ){ 
-               $res = wfQuery("SELECT lcc_cacheobj FROM linkscc WHERE lcc_title = '{$dbkeyfrom}'", 
+       /* private */ function fillFromLinkscc( $id ){ 
+               $id = IntVal( $id );
+               $res = wfQuery("SELECT lcc_cacheobj FROM linkscc WHERE lcc_pageid = $id", 
                        DB_READ);
                $row = wfFetchObject( $res );
                if( $row == FALSE)
@@ -297,15 +297,15 @@ class LinkCache {
                } else {
                        $ser = wfStrencode( serialize( $this ) );
                }
-               wfQuery("REPLACE INTO linkscc(lcc_pageid,lcc_title,lcc_cacheobj) " .
-                       "VALUES({$pid}, '{$dbkeyfrom}', '{$ser}')", DB_WRITE);
+               wfQuery("REPLACE INTO linkscc(lcc_pageid,lcc_cacheobj) " .
+                       "VALUES({$pid}, '{$ser}')", DB_WRITE);
        }
 
        # $pid is a page id
        /* static */ function linksccClearLinksTo( $pid ){
                $pid = intval( $pid );
                wfQuery("DELETE linkscc FROM linkscc,links ".
-                       "WHERE lcc_title=links.l_from AND l_to={$pid}", DB_WRITE);
+                       "WHERE lcc_pageid=links.l_from AND l_to={$pid}", DB_WRITE);
                wfQuery("DELETE FROM linkscc WHERE lcc_pageid='{$pid}'", DB_WRITE);
        }