From: Tim Starling Date: Sun, 24 Apr 2005 04:13:47 +0000 (+0000) Subject: new function: getBrokenLinksFrom() X-Git-Tag: 1.5.0alpha1~162 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=a23dadf7a59f86cc1ff41074a40430f3818891e6;p=lhc%2Fweb%2Fwiklou.git new function: getBrokenLinksFrom() --- diff --git a/includes/Title.php b/includes/Title.php index eb79258121..756705ea09 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1377,6 +1377,39 @@ class Title { return $retVal; } + + /** + * Get an array of Title objects referring to non-existent articles linked from this page + * + * @param string $options may be FOR UPDATE + * @return array the Title objects + * @access public + */ + function getBrokenLinksFrom( $options = '' ) { + global $wgLinkCache; + + if ( $options ) { + $db =& wfGetDB( DB_MASTER ); + } else { + $db =& wfGetDB( DB_SLAVE ); + } + $page = $db->tableName( 'page' ); + $brokenlinks = $db->tableName( 'brokenlinks' ); + $id = $this->getArticleID(); + + $sql = "SELECT bl_to FROM $brokenlinks WHERE bl_from=$id $options"; + $res = $db->query( $sql, "Title::getBrokenLinksFrom" ); + $retVal = array(); + if ( $db->numRows( $res ) ) { + while ( $row = $db->fetchObject( $res ) ) { + $retVal[] = Title::newFromText( $row->bl_to ); + } + } + $db->freeResult( $res ); + return $retVal; + } + + /** * Get a list of URLs to purge from the Squid cache when this * page changes