r63007 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63006‎ | r63007 | r63008 >
Date:13:58, 26 February 2010
Author:happydog
Status:ok
Tags:
Comment:
CodeReview: Fixed some errors I introduced in r62954 (thanks nikerabbit).

* $cacheSize != "all" didn't work due to type conversion, so it now uses !==. I also force the supplied argument to lower-case to make it case-insensitive (which actually negates the need for !==, but there you go).
* Changed the is_numeric() check to use a regex to match a string of digits (i.e. a positive integer or zero), as is_numeric() allows through all kinds of weird input.
* The later check for ($cacheSize != 0) was incorrect because "all" would be type-cast to 0. It now uses !== instead.
Modified paths:
  • /trunk/extensions/CodeReview/svnImport.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/svnImport.php
@@ -23,8 +23,8 @@
2424 $cacheSize = 0;
2525 if ( $this->hasOption( 'precache' ) ) {
2626 $cacheSize = $this->getOption( 'precache' );
27 - if ( $cacheSize != "all" ) {
28 - if ( is_numeric( $cacheSize ) && $cacheSize >= 0 ) {
 27+ if ( strtolower( $cacheSize ) !== "all" ) {
 28+ if ( preg_match( '/^\d+$/', $cacheSize ) ) {
2929 $cacheSize = intval( $cacheSize );
3030 } else {
3131 $this->error( "Invalid argument for --precache (must be a positive integer, 0 or 'all')", true );
@@ -108,7 +108,7 @@
109109 wfWaitForSlaves( 5 );
110110 }
111111
112 - if ( $cacheSize != 0 ) {
 112+ if ( $cacheSize !== 0 ) {
113113 $dbw = wfGetDB( DB_MASTER );
114114 $options = array( 'ORDER BY' => 'cr_id DESC' );
115115

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r62954CodeReview: Changed the 'precache' argument to svnImport.php so that precachi...happydog11:44, 25 February 2010

Status & tagging log