r32163 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32162‎ | r32163 | r32164 >
Date:11:19, 19 March 2008
Author:tstarling
Status:old
Tags:
Comment:
Fixed no-op update query in common code path
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/Database.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -3372,31 +3372,35 @@
33733373 $insertCats = array_merge( $added, $deleted );
33743374 $insertRows = array();
33753375 foreach( $insertCats as $cat ) {
3376 - $insertRows []= array( 'cat_title' => $cat );
 3376+ $insertRows[] = array( 'cat_title' => $cat );
33773377 }
33783378 $dbw->insert( 'category', $insertRows, __METHOD__, 'IGNORE' );
33793379
33803380 $addFields = array( 'cat_pages = cat_pages + 1' );
33813381 $removeFields = array( 'cat_pages = cat_pages - 1' );
33823382 if( $ns == NS_CATEGORY ) {
3383 - $addFields []= 'cat_subcats = cat_subcats + 1';
3384 - $removeFields []= 'cat_subcats = cat_subcats - 1';
 3383+ $addFields[] = 'cat_subcats = cat_subcats + 1';
 3384+ $removeFields[] = 'cat_subcats = cat_subcats - 1';
33853385 } elseif( $ns == NS_IMAGE ) {
3386 - $addFields []= 'cat_files = cat_files + 1';
3387 - $removeFields []= 'cat_files = cat_files - 1';
 3386+ $addFields[] = 'cat_files = cat_files + 1';
 3387+ $removeFields[] = 'cat_files = cat_files - 1';
33883388 }
33893389
3390 - $dbw->update(
3391 - 'category',
3392 - $addFields,
3393 - array( 'cat_title' => $added ),
3394 - __METHOD__
3395 - );
3396 - $dbw->update(
3397 - 'category',
3398 - $removeFields,
3399 - array( 'cat_title' => $deleted ),
3400 - __METHOD__
3401 - );
 3390+ if ( $added ) {
 3391+ $dbw->update(
 3392+ 'category',
 3393+ $addFields,
 3394+ array( 'cat_title' => $added ),
 3395+ __METHOD__
 3396+ );
 3397+ }
 3398+ if ( $deleted ) {
 3399+ $dbw->update(
 3400+ 'category',
 3401+ $removeFields,
 3402+ array( 'cat_title' => $deleted ),
 3403+ __METHOD__
 3404+ );
 3405+ }
34023406 }
34033407 }
Index: trunk/phase3/includes/Database.php
@@ -1569,8 +1569,7 @@
15701570 $list .= "$value";
15711571 } elseif ( ($mode == LIST_AND || $mode == LIST_OR) && is_array($value) ) {
15721572 if( count( $value ) == 0 ) {
1573 - // Empty input... or should this throw an error?
1574 - $list .= '0';
 1573+ throw new MWException( __METHOD__.': empty input' );
15751574 } elseif( count( $value ) == 1 ) {
15761575 // Special-case single values, as IN isn't terribly efficient
15771576 $list .= $field." = ".$this->addQuotes( $value[0] );

Status & tagging log