r56571 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56570‎ | r56571 | r56572 >
Date:22:25, 17 September 2009
Author:thomasv
Status:ok (Comments)
Tags:
Comment:
escape page titles
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -1180,6 +1180,7 @@
11811181
11821182 $index_title = $index->mTitle;
11831183 $index_id = $index->getID();
 1184+ $dbr = wfGetDB( DB_SLAVE );
11841185
11851186 //read the list of pages
11861187 $pages = array();
@@ -1199,12 +1200,11 @@
12001201 } else {
12011202 $n = count($links[1]);
12021203 for ( $i = 0; $i < $n; $i++ ) {
1203 - $page = str_replace( ' ' , '_' , $links[1][$i] );
 1204+ $page = $dbr->strencode( str_replace( ' ' , '_' , $links[1][$i] ) );
12041205 if($page != $deletedpage) array_push( $pages, $page );
12051206 }
12061207 }
12071208
1208 - $dbr = wfGetDB( DB_SLAVE );
12091209 $catlinks = $dbr->tableName( 'categorylinks' );
12101210 $page = $dbr->tableName( 'page' );
12111211 $pagelist = "'".implode( "', '", $pages)."'";

Comments

#Comment by Brion VIBBER (talk | contribs)   16:18, 22 September 2009

This code is fine for now, but it may be easier to maintain using the db wrappers... $dbr->selectRow() should be able to build this query just fine, we can pass in the $pages array as a where parameter and it can handle building the IN(...) list and escaping for us.

Status & tagging log