r71629 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71628‎ | r71629 | r71630 >
Date:15:38, 25 August 2010
Author:reedy
Status:ok
Tags:
Comment:
Braces for MaxSem
Modified paths:
  • /trunk/phase3/includes/db/DatabaseSqlite.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabaseSqlite.php
@@ -197,25 +197,29 @@
198198 }
199199
200200 function freeResult( $res ) {
201 - if ( $res instanceof ResultWrapper )
 201+ if ( $res instanceof ResultWrapper ) {
202202 $res->result = null;
203 - else
 203+ } else {
204204 $res = null;
 205+ }
205206 }
206207
207208 function fetchObject( $res ) {
208 - if ( $res instanceof ResultWrapper )
 209+ if ( $res instanceof ResultWrapper ) {
209210 $r =& $res->result;
210 - else
 211+ } else {
211212 $r =& $res;
 213+ }
212214
213215 $cur = current( $r );
214216 if ( is_array( $cur ) ) {
215217 next( $r );
216218 $obj = new stdClass;
217 - foreach ( $cur as $k => $v )
218 - if ( !is_numeric( $k ) )
 219+ foreach ( $cur as $k => $v ) {
 220+ if ( !is_numeric( $k ) ) {
219221 $obj->$k = $v;
 222+ }
 223+ }
220224
221225 return $obj;
222226 }
@@ -223,11 +227,11 @@
224228 }
225229
226230 function fetchRow( $res ) {
227 - if ( $res instanceof ResultWrapper )
 231+ if ( $res instanceof ResultWrapper ) {
228232 $r =& $res->result;
229 - else
 233+ } else {
230234 $r =& $res;
231 -
 235+ }
232236 $cur = current( $r );
233237 if ( is_array( $cur ) ) {
234238 next( $r );
@@ -280,19 +284,23 @@
281285 }
282286
283287 function dataSeek( $res, $row ) {
284 - if ( $res instanceof ResultWrapper )
 288+ if ( $res instanceof ResultWrapper ) {
285289 $r =& $res->result;
286 - else
 290+ } else {
287291 $r =& $res;
 292+ }
288293 reset( $r );
289 - if ( $row > 0 )
290 - for ( $i = 0; $i < $row; $i++ )
 294+ if ( $row > 0 ) {
 295+ for ( $i = 0; $i < $row; $i++ ) {
291296 next( $r );
 297+ }
 298+ }
292299 }
293300
294301 function lastError() {
295 - if ( !is_object( $this->mConn ) )
 302+ if ( !is_object( $this->mConn ) ) {
296303 return "Cannot return last error, no db connection";
 304+ }
297305 $e = $this->mConn->errorInfo();
298306 return isset( $e[2] ) ? $e[2] : '';
299307 }
@@ -355,9 +363,11 @@
356364 * Filter the options used in SELECT statements
357365 */
358366 function makeSelectOptions( $options ) {
359 - foreach ( $options as $k => $v )
360 - if ( is_numeric( $k ) && $v == 'FOR UPDATE' )
 367+ foreach ( $options as $k => $v ) {
 368+ if ( is_numeric( $k ) && $v == 'FOR UPDATE' ) {
361369 $options[$k] = '';
 370+ }
 371+ }
362372 return parent::makeSelectOptions( $options );
363373 }
364374
@@ -365,20 +375,28 @@
366376 * Based on generic method (parent) with some prior SQLite-sepcific adjustments
367377 */
368378 function insert( $table, $a, $fname = 'DatabaseSqlite::insert', $options = array() ) {
369 - if ( !count( $a ) ) return true;
370 - if ( !is_array( $options ) ) $options = array( $options );
 379+ if ( !count( $a ) ) {
 380+ return true;
 381+ }
 382+ if ( !is_array( $options ) ) {
 383+ $options = array( $options );
 384+ }
371385
372386 # SQLite uses OR IGNORE not just IGNORE
373 - foreach ( $options as $k => $v )
374 - if ( $v == 'IGNORE' )
 387+ foreach ( $options as $k => $v ) {
 388+ if ( $v == 'IGNORE' ) {
375389 $options[$k] = 'OR IGNORE';
 390+ }
 391+ }
376392
377393 # SQLite can't handle multi-row inserts, so divide up into multiple single-row inserts
378394 if ( isset( $a[0] ) && is_array( $a[0] ) ) {
379395 $ret = true;
380 - foreach ( $a as $k => $v )
381 - if ( !parent::insert( $table, $v, "$fname/multi-row", $options ) )
 396+ foreach ( $a as $k => $v ) {
 397+ if ( !parent::insert( $table, $v, "$fname/multi-row", $options ) ) {
382398 $ret = false;
 399+ }
 400+ }
383401 } else {
384402 $ret = parent::insert( $table, $a, "$fname/single-row", $options );
385403 }
@@ -392,9 +410,11 @@
393411 # SQLite can't handle multi-row replaces, so divide up into multiple single-row queries
394412 if ( isset( $rows[0] ) && is_array( $rows[0] ) ) {
395413 $ret = true;
396 - foreach ( $rows as $k => $v )
397 - if ( !parent::replace( $table, $uniqueIndexes, $v, "$fname/multi-row" ) )
 414+ foreach ( $rows as $k => $v ) {
 415+ if ( !parent::replace( $table, $uniqueIndexes, $v, "$fname/multi-row" ) ) {
398416 $ret = false;
 417+ }
 418+ }
399419 } else {
400420 $ret = parent::replace( $table, $uniqueIndexes, $rows, "$fname/single-row" );
401421 }

Status & tagging log