r75686 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75685‎ | r75686 | r75687 >
Date:22:26, 29 October 2010
Author:reedy
Status:ok
Tags:
Comment:
Fixup crappily built query (not brilliant, but better)
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php
@@ -471,21 +471,18 @@
472472 $page_namespace = $this->page_namespace;
473473 $dbr = wfGetDB( DB_SLAVE );
474474 $catlinks = $dbr->tableName( 'categorylinks' );
 475+
 476+ $values = array();
475477 foreach ( $page_ids as $id => $pdbk ) {
476478 // consider only link in page namespace
477479 if ( preg_match( "/^$page_namespace:(.*?)$/", $pdbk ) ) {
478480 $colours[$pdbk] = 'quality1';
479 - if ( !isset( $query ) ) {
480 - $query = "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN(";
481 - } else {
482 - $query .= ', ';
483 - }
484 - $query .= intval( $id );
 481+ $values[] = intval( $id );
485482 }
486483 }
487484
488 - if ( isset( $query ) ) {
489 - $query .= ')';
 485+ if ( count( $values ) ) {
 486+ $query .= "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN(" . implode( ",", $values ) . ")";
490487 $res = $dbr->query( $query, __METHOD__ );
491488
492489 foreach ( $res as $x ) {

Status & tagging log