# 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 ) {
# 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 );
$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
# 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
$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;