r56834 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56833‎ | r56834 | r56835 >
Date:20:38, 23 September 2009
Author:thomasv
Status:ok (Comments)
Tags:
Comment:
escaping string passed to SQL; fixing slow query
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -1194,7 +1194,7 @@
11951195 if ( $image && $image->isMultiPage() && $image->pageCount() ) {
11961196 $n = $image->pageCount();
11971197 for ( $i = 1; $i <= $n; $i++ ) {
1198 - $page = $index_title->getDBKey().'/'.$i;
 1198+ $page = $dbr->strencode( $index_title->getDBKey().'/'.$i );
11991199 if($page != $deletedpage) array_push( $pages, $page );
12001200 }
12011201 }
@@ -1270,7 +1270,7 @@
12711271 $catlinks = $dbr->tableName( 'categorylinks' );
12721272
12731273 # count transclusions from page namespace
1274 - $query = "SELECT COUNT(page_id) AS count FROM $templatelinks LEFT JOIN $page ON page_title=tl_title where tl_from=$id and tl_namespace=$page_ns_index";
 1274+ $query = "SELECT COUNT(page_id) AS count FROM $templatelinks LEFT JOIN $page ON page_title=tl_title AND page_namespace=tl_namespace WHERE tl_from=$id AND tl_namespace=$page_ns_index";
12751275 $res = $dbr->query( $query , __METHOD__ );
12761276 if( $res && $dbr->numRows( $res ) > 0 ) {
12771277 $row = $dbr->fetchObject( $res );
@@ -1282,7 +1282,7 @@
12831283 }
12841284
12851285 # find the proofreading status of transclusions
1286 - $query = "SELECT COUNT(page_id) AS count FROM $templatelinks LEFT JOIN $page ON page_title=tl_title LEFT JOIN $catlinks ON cl_from=page_id where tl_from=$id and tl_namespace=$page_ns_index AND cl_to='###'";
 1286+ $query = "SELECT COUNT(page_id) AS count FROM $templatelinks LEFT JOIN $page ON page_title=tl_title AND page_namespace=tl_namespace LEFT JOIN $catlinks ON cl_from=page_id WHERE tl_from=$id AND tl_namespace=$page_ns_index AND cl_to='###'";
12871287 $n0 = pr_query_count( $dbr, $query, 'proofreadpage_quality0_category' );
12881288 $n2 = pr_query_count( $dbr, $query, 'proofreadpage_quality2_category' );
12891289 $n3 = pr_query_count( $dbr, $query, 'proofreadpage_quality3_category' );

Comments

#Comment by Brion VIBBER (talk | contribs)   17:24, 24 September 2009

Fixes remaining SQL bugs from r56825

Status & tagging log