r47434 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47433‎ | r47434 | r47435 >
Date:08:35, 18 February 2009
Author:tstarling
Status:deferred
Tags:
Comment:
Fixed Title::getBrokenLinksFrom(), totally broken by r47374. Caused breakage of Special:BrokenRedirects on Wikimedia. Removed $options parameter, it was not used anywhere and definitely should never be used anywhere due to the risk of breaking the wiki. Brought the coding style into this century.
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -2443,42 +2443,35 @@
24442444 * Get an array of Title objects referring to non-existent articles linked from this page
24452445 *
24462446 * @todo check if needed (used only in SpecialBrokenRedirects.php, and should use redirect table in this case)
2447 - * @param array $options may be FOR UPDATE
24482447 * @return \type{\arrayof{Title}} the Title objects
24492448 */
2450 - public function getBrokenLinksFrom( $options = array() ) {
 2449+ public function getBrokenLinksFrom() {
24512450 if ( $this->getArticleId() == 0 ) {
24522451 # All links from article ID 0 are false positives
24532452 return array();
24542453 }
24552454
2456 - if ( count( $options ) > 0 ) {
2457 - $db = wfGetDB( DB_MASTER );
2458 - } else {
2459 - $db = wfGetDB( DB_SLAVE );
2460 - }
 2455+ $dbr = wfGetDB( DB_SLAVE );
 2456+ $res = $dbr->select(
 2457+ array( 'page', 'pagelinks' ),
 2458+ array( 'pl_namespace', 'pl_title' ),
 2459+ array(
 2460+ 'pl_from' => $this->getArticleId(),
 2461+ 'page_namespace IS NULL'
 2462+ ),
 2463+ __METHOD__, array(),
 2464+ array(
 2465+ 'page' => array(
 2466+ 'LEFT JOIN',
 2467+ array( 'pl_namespace=page_namespace', 'pl_title=page_title' )
 2468+ )
 2469+ )
 2470+ );
24612471
2462 - $res = $db->safeQuery(
2463 - "SELECT pl_namespace, pl_title
2464 - FROM !
2465 - LEFT JOIN !
2466 - ON pl_namespace=page_namespace
2467 - AND pl_title=page_title
2468 - WHERE pl_from=?
2469 - AND page_namespace IS NULL
2470 - !",
2471 - $db->tableName( 'pagelinks' ),
2472 - $db->tableName( 'page' ),
2473 - $this->getArticleId(),
2474 - $options );
2475 -
24762472 $retVal = array();
2477 - if ( $db->numRows( $res ) ) {
2478 - foreach( $res as $row ) {
2479 - $retVal[] = Title::makeTitle( $row->pl_namespace, $row->pl_title );
2480 - }
 2473+ foreach( $res as $row ) {
 2474+ $retVal[] = Title::makeTitle( $row->pl_namespace, $row->pl_title );
24812475 }
2482 - $db->freeResult( $res );
24832476 return $retVal;
24842477 }
24852478

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r47374General cleanup of SQL in Title and File. Fixes bug 17392: 'FOR UPDATE' shoul...demon19:03, 17 February 2009

Status & tagging log