From 3decbc36a11da22330c4db504a37d7fe53cb9a2f Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 2 Feb 2013 22:12:06 -0800 Subject: [PATCH] Fixed E_STRICT notices in PostgresUpdater::renameIndex(). * This function has to the match base function to avoid warnings. Change-Id: I66fbfe6528fe4f4ff56cba62d446d9a359edc658 --- includes/installer/PostgresUpdater.php | 31 ++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index 3b1f7d0aef..a1c5a22b0f 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -537,11 +537,34 @@ END; } } - protected function renameIndex( $table, $old, $new ) { - if ( $this->db->indexExists( $table, $old ) ) { - $this->output( "Renaming index $old to $new\n" ); - $this->db->query( "ALTER INDEX $old RENAME TO $new" ); + protected function renameIndex( + $table, $old, $new, $skipBothIndexExistWarning = false, $a = false, $b = false + ) { + // First requirement: the table must exist + if ( !$this->db->tableExists( $table, __METHOD__ ) ) { + $this->output( "...skipping: '$table' table doesn't exist yet.\n" ); + return; + } + + // Second requirement: the new index must be missing + if ( $this->db->indexExists( $table, $new, __METHOD__ ) ) { + $this->output( "...index $new already set on $table table.\n" ); + if ( !$skipBothIndexExistWarning + && $this->db->indexExists( $table, $old, __METHOD__ ) ) + { + $this->output( "...WARNING: $old still exists, despite it has been renamed into $new (which also exists).\n" . + " $old should be manually removed if not needed anymore.\n" ); + } + return; } + + // Third requirement: the old index must exist + if ( !$this->db->indexExists( $table, $old, __METHOD__ ) ) { + $this->output( "...skipping: index $old doesn't exist.\n" ); + return; + } + + $this->db->query( "ALTER INDEX $old RENAME TO $new" ); } protected function addPgField( $table, $field, $type ) { -- 2.20.1