From aa6ed109f390b43c09c326d0e282e79f5fcf39f3 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Mon, 5 Jul 2004 02:57:44 +0000 Subject: [PATCH] Select for update when getting links to swap. Hopefully this will fix one cause of key collision and hence link table corruption seen recently --- includes/Title.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 87d7e96674..d54c0a9276 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -770,10 +770,10 @@ class Title { # Get an array of Title objects linking to this title # Also stores the IDs in the link cache - function getLinksTo() { + function getLinksTo( $options = '' ) { global $wgLinkCache; $id = $this->getArticleID(); - $sql = "SELECT cur_namespace,cur_title,cur_id FROM cur,links WHERE l_from=cur_id AND l_to={$id}"; + $sql = "SELECT cur_namespace,cur_title,cur_id FROM cur,links WHERE l_from=cur_id AND l_to={$id} $options"; $res = wfQuery( $sql, DB_READ, "Title::getLinksTo" ); $retVal = array(); if ( wfNumRows( $res ) ) { @@ -790,11 +790,11 @@ class Title { # Get an array of Title objects linking to this non-existent title # Also stores the IDs in the link cache - function getBrokenLinksTo() { + function getBrokenLinksTo( $options = '' ) { global $wgLinkCache; $encTitle = wfStrencode( $this->getPrefixedDBkey() ); $sql = "SELECT cur_namespace,cur_title,cur_id FROM brokenlinks,cur " . - "WHERE bl_from=cur_id AND bl_to='$encTitle'"; + "WHERE bl_from=cur_id AND bl_to='$encTitle' $options"; $res = wfQuery( $sql, DB_READ, "Title::getBrokenLinksTo" ); $retVal = array(); if ( wfNumRows( $res ) ) { @@ -955,8 +955,8 @@ class Title { # Swap links # Load titles and IDs - $linksToOld = $this->getLinksTo(); - $linksToNew = $nt->getLinksTo(); + $linksToOld = $this->getLinksTo( 'FOR UPDATE' ); + $linksToNew = $nt->getLinksTo( 'FOR UPDATE' ); # Delete them all $sql = "DELETE FROM links WHERE l_to=$oldid OR l_to=$newid"; -- 2.20.1