-
- /**
- * Update any brokenlinks *to* this page
- * Call for a newly created page, or just to make sure state is consistent
- */
- function fixBrokenLinks() {
- $fname = 'LinksUpdate::fixBrokenLinks';
-
- $dbw =& wfGetDB( DB_MASTER );
- $page = $dbw->tableName( 'page' );
- $links = $dbw->tableName( 'links' );
-
- $res = $dbw->select( 'brokenlinks', array( 'bl_from' ), array( 'bl_to' => $this->mTitle ),
- $fname, 'FOR UPDATE' );
- if ( 0 == $dbw->numRows( $res ) ) { return; }
-
- $arr=array();
- $now = $dbw->timestamp();
- $sql2 = "UPDATE $page SET page_touched='{$now}' WHERE page_id IN (";
- $first = true;
- while ( $row = $dbw->fetchObject( $res ) ) {
- if ( ! $first ) { $sql2 .= ","; }
- $first = false;
- array_push( $arr, array(
- 'l_from' => $row->bl_from,
- 'l_to' => $this->mId ) );
- $sql2 .= $row->bl_from;
- }
- $sql2 .= ')';
-
- # 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
- $dbw->insert( 'links', $arr, $fname, array( 'IGNORE' ) );
- $dbw->query( $sql2, $fname );
- $dbw->delete( 'brokenlinks', array( 'bl_to' => $this->mTitle ), $fname );
- }