Modification to LinkBatch
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 3 Apr 2005 08:26:42 +0000 (08:26 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 3 Apr 2005 08:26:42 +0000 (08:26 +0000)
includes/LinkCache.php

index 4ab4482..4a57909 100644 (file)
@@ -405,6 +405,9 @@ class LinkBatch {
        }
 
        function add( $ns, $dbkey ) {
+               if ( $ns < 0 ) {
+                       return;
+               }
                if ( !array_key_exists( $ns, $this->data ) ) {
                        $this->data[$ns] = array();
                }
@@ -458,16 +461,18 @@ class LinkBatch {
                $res = $dbr->query( $sql, $fname );
 
                // Process results
-               // For each returned entry, add it to the list of good links, and remove it from $data
+               // For each returned entry, add it to the list of good links, and remove it from $remaining
+
+               $remaining = $this->data;
                while ( $row = $dbr->fetchObject( $res ) ) {
                        $title = Title::makeTitle( $row->page_namespace, $row->page_title );
                        $cache->addGoodLink( $row->page_id, $title->getPrefixedDBkey() );
-                       unset( $this->data[$row->page_namespace][$row->page_title] );
+                       unset( $remaining[$row->page_namespace][$row->page_title] );
                }
                $dbr->freeResult( $res );
 
                // The remaining links in $data are bad links, register them as such
-               foreach ( $this->data as $ns => $dbkeys ) {
+               foreach ( $remaining as $ns => $dbkeys ) {
                        foreach ( $dbkeys as $dbkey => $nothing ) {
                                $title = Title::makeTitle( $ns, $dbkey );
                                $cache->addBadLink( $title->getPrefixedText() );