From afb297d175963d19735735c0283396a6cdcdf35a Mon Sep 17 00:00:00 2001 From: lethosor Date: Sun, 26 Jan 2014 11:49:16 -0500 Subject: [PATCH] Fix rebuildall.php fatal error with PostgreSQL The fix for 47055 introduced a fatal error when running rebuildall.php. This is a workaround suggested by gebhkla on Bugzilla (idle for 10+ days). It just checks to make sure $options is actually an array before calling array_search on it. Bug: 60094 Change-Id: Ib54420b5a749c60b82a4757a9f5fa511f48fdb72 --- includes/db/DatabasePostgres.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 83d8cae0cf..8f93d50280 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -828,13 +828,15 @@ __INDEXATTR__; * so causes a DB error. This wrapper checks which tables can be locked and adjusts it accordingly. */ function selectSQLText( $table, $vars, $conds = '', $fname = __METHOD__, $options = array(), $join_conds = array() ) { - $forUpdateKey = array_search( 'FOR UPDATE', $options ); - if ( $forUpdateKey !== false && $join_conds ) { - unset( $options[$forUpdateKey] ); - - foreach ( $join_conds as $table => $join_cond ) { - if ( 0 === preg_match( '/^(?:LEFT|RIGHT|FULL)(?: OUTER)? JOIN$/i', $join_cond[0] ) ) { - $options['FOR UPDATE'][] = $table; + if ( is_array( $options ) ) { + $forUpdateKey = array_search( 'FOR UPDATE', $options ); + if ( $forUpdateKey !== false && $join_conds ) { + unset( $options[$forUpdateKey] ); + + foreach ( $join_conds as $table => $join_cond ) { + if ( 0 === preg_match( '/^(?:LEFT|RIGHT|FULL)(?: OUTER)? JOIN$/i', $join_cond[0] ) ) { + $options['FOR UPDATE'][] = $table; + } } } } -- 2.20.1