Merge "installer: Replace bad calls to getText() on DBQueryError exceptions"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 24 May 2017 11:34:20 +0000 (11:34 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 24 May 2017 11:34:20 +0000 (11:34 +0000)
1  2 
includes/installer/MysqlInstaller.php

@@@ -179,8 -179,8 +179,8 @@@ class MysqlInstaller extends DatabaseIn
  
                # Determine existing default character set
                if ( $conn->tableExists( "revision", __METHOD__ ) ) {
 -                      $revision = $conn->buildLike( $this->getVar( 'wgDBprefix' ) . 'revision' );
 -                      $res = $conn->query( "SHOW TABLE STATUS $revision", __METHOD__ );
 +                      $revision = $this->escapeLikeInternal( $this->getVar( 'wgDBprefix' ) . 'revision', '\\' );
 +                      $res = $conn->query( "SHOW TABLE STATUS LIKE '$revision'", __METHOD__ );
                        $row = $conn->fetchObject( $res );
                        if ( !$row ) {
                                $this->parent->showMessage( 'config-show-table-status' );
                $wgDBpassword = $this->getVar( '_InstallPassword' );
        }
  
 +      /**
 +       * @param string $s
 +       * @return string
 +       */
 +      protected function escapeLikeInternal( $s, $escapeChar = '`' ) {
 +              return str_replace( [ $escapeChar, '%', '_' ],
 +                      [ "{$escapeChar}{$escapeChar}", "{$escapeChar}%", "{$escapeChar}_" ],
 +                      $s );
 +      }
 +
        /**
         * Get a list of storage engines that are available and supported
         *
                                                        // If we couldn't create for some bizzare reason and the
                                                        // user probably doesn't exist, skip the grant
                                                        $this->db->rollback( __METHOD__ );
-                                                       $status->warning( 'config-install-user-create-failed', $dbUser, $dqe->getText() );
+                                                       $status->warning( 'config-install-user-create-failed', $dbUser, $dqe->getMessage() );
                                                }
                                        }
                                } else {
                                $this->db->commit( __METHOD__ );
                        } catch ( DBQueryError $dqe ) {
                                $this->db->rollback( __METHOD__ );
-                               $status->fatal( 'config-install-user-grant-failed', $dbUser, $dqe->getText() );
+                               $status->fatal( 'config-install-user-grant-failed', $dbUser, $dqe->getMessage() );
                        }
                }