http://www.mediawiki.org/wiki/Special:Code/MediaWiki/75686
Revision: 75686 Author: reedy Date: 2010-10-29 22:26:25 +0000 (Fri, 29 Oct 2010) Log Message: ----------- Fixup crappily built query (not brilliant, but better) Modified Paths: -------------- trunk/extensions/ProofreadPage/ProofreadPage_body.php Modified: trunk/extensions/ProofreadPage/ProofreadPage_body.php =================================================================== --- trunk/extensions/ProofreadPage/ProofreadPage_body.php 2010-10-29 22:24:13 UTC (rev 75685) +++ trunk/extensions/ProofreadPage/ProofreadPage_body.php 2010-10-29 22:26:25 UTC (rev 75686) @@ -471,21 +471,18 @@ $page_namespace = $this->page_namespace; $dbr = wfGetDB( DB_SLAVE ); $catlinks = $dbr->tableName( 'categorylinks' ); + + $values = array(); foreach ( $page_ids as $id => $pdbk ) { // consider only link in page namespace if ( preg_match( "/^$page_namespace:(.*?)$/", $pdbk ) ) { $colours[$pdbk] = 'quality1'; - if ( !isset( $query ) ) { - $query = "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN("; - } else { - $query .= ', '; - } - $query .= intval( $id ); + $values[] = intval( $id ); } } - if ( isset( $query ) ) { - $query .= ')'; + if ( count( $values ) ) { + $query .= "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN(" . implode( ",", $values ) . ")"; $res = $dbr->query( $query, __METHOD__ ); foreach ( $res as $x ) { _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs