r84874 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84873‎ | r84874 | r84875 >
Date:19:07, 27 March 2011
Author:demon
Status:reverted (Comments)
Tags:
Comment:
Clean up extra needless preg_match() calls done on every BeforePageDisplay call, even when we're not in an affected namespace
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php
@@ -311,23 +311,22 @@
312312 }
313313 $out->proofreadPageDone = true;
314314
315 - $page_namespace = $this->page_namespace;
316 - if ( preg_match( "/^$page_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) {
317 - $this->preparePage( $out, $m, $isEdit );
318 - return true;
 315+ switch( $wgTitle->getNamespace() ) {
 316+ case $this->page_namespace:
 317+ if ( preg_match( "/^{$this->page_namespace}:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) {
 318+ $this->preparePage( $out, $m, $isEdit );
 319+ return true;
 320+ }
 321+ break;
 322+ case $this->index_namespace:
 323+ $this->prepareIndex( $out );
 324+ break;
 325+ case NS_MAIN:
 326+ $this->prepareArticle( $out );
 327+ break;
319328 }
 329+ return true;
320330
321 - $index_namespace = $this->index_namespace;
322 - if ( $isEdit && ( preg_match( "/^$index_namespace:(.*?)(\/([0-9]*)|)$/", $wgTitle->getPrefixedText(), $m ) ) ) {
323 - $this->prepareIndex( $out );
324 - return true;
325 - }
326 -
327 - if( $wgTitle->getNamespace() == NS_MAIN ) {
328 - $this->prepareArticle( $out );
329 - return true;
330 - }
331 -
332331 return true;
333332 }
334333

Follow-up revisions

RevisionCommit summaryAuthorDate
r92300Revert r84874: breaks ProofreadPage's UI completely by incorrectly comparing ...brion20:30, 15 July 2011
r92322MFT r92300 - revert r84874 accidental breakage in ProofreadPagebrion22:05, 15 July 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   18:40, 15 July 2011

This doesn't seem ok at all -- it changes from a string comparison against a string to a string comparison against a number.

#Comment by Brion VIBBER (talk | contribs)   20:32, 15 July 2011

Confirmed in IRC that that was just a brain fart -- reverting in r92300. Switching to use $title->getNsText() will probably work... unless a non-real namespace is being used, which is still supported by the current code. Ick. :) We'll clear it up later!

Status & tagging log