The link cache is constructed without FOR UPDATE, so collisions in these insert state...
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 5 Jul 2004 03:02:47 +0000 (03:02 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 5 Jul 2004 03:02:47 +0000 (03:02 +0000)
includes/LinksUpdate.php

index 104e442..5d29390 100644 (file)
@@ -54,7 +54,10 @@ class LinksUpdate {
                # Do the insertion
                $sql = "";
                if ( 0 != count( $add ) ) {
-                       $sql = "INSERT INTO links (l_from,l_to) VALUES ";
+                       # The link cache was constructed without FOR UPDATE, so there may be collisions
+                       # Ignoring for now, I'm not sure if that causes problems or not, but I'm fairly
+                       # sure it's better than without IGNORE
+                       $sql = "INSERT IGNORE INTO links (l_from,l_to) VALUES ";
                        $first = true;
                        foreach( $add as $lt => $lid ) {
                                
@@ -90,7 +93,7 @@ class LinksUpdate {
                # Do additions
                $sql = "";
                if ( 0 != count ( $add ) ) {
-                       $sql = "INSERT INTO brokenlinks (bl_from,bl_to) VALUES ";
+                       $sql = "INSERT IGNORE INTO brokenlinks (bl_from,bl_to) VALUES ";
                        $first = true;
                        foreach( $add as $blt ) {
                                $blt = wfStrencode( $blt );
@@ -116,7 +119,7 @@ class LinksUpdate {
                $sql = "";
                $image = Namespace::getImage();
                if ( 0 != count ( $add ) ) {
-                       $sql = "INSERT INTO imagelinks (il_from,il_to) VALUES ";
+                       $sql = "INSERT IGNORE INTO imagelinks (il_from,il_to) VALUES ";
                        $first = true;
                        foreach( $add as $iname => $val ) {
                                # FIXME: Change all this to avoid unnecessary duplication
@@ -145,7 +148,7 @@ class LinksUpdate {
                        # Do the insertion
                        $sql = "";
                        if ( 0 != count ( $add ) ) {
-                               $sql = "INSERT INTO categorylinks (cl_from,cl_to,cl_sortkey) VALUES ";
+                               $sql = "INSERT IGNORE INTO categorylinks (cl_from,cl_to,cl_sortkey) VALUES ";
                                $first = true;
                                foreach( $add as $cname => $sortkey ) {
                                        # FIXME: Change all this to avoid unnecessary duplication
@@ -284,7 +287,9 @@ class LinksUpdate {
                $res = wfQuery( $sql, DB_READ, $fname );
                if ( 0 == wfNumRows( $res ) ) { return; }
 
-               $sql = "INSERT INTO links (l_from,l_to) VALUES ";
+               # Ignore errors. If a link existed in both the brokenlinks table and the links 
+               # table, that's an error which can be fixed at this stage by simply ignoring collisions
+               $sql = "INSERT IGNORE INTO links (l_from,l_to) VALUES ";
                $now = wfTimestampNow();
                $sql2 = "UPDATE cur SET cur_touched='{$now}' WHERE cur_id IN (";
                $first = true;