Merge "Align "What's this" vertically"
[lhc/web/wiklou.git] / includes / libs / rdbms / database / DatabaseMysqlBase.php
index e237ef4..3c4cda5 100644 (file)
@@ -51,6 +51,8 @@ abstract class DatabaseMysqlBase extends Database {
        /** @var string|null */
        protected $sslCertPath;
        /** @var string|null */
+       protected $sslCAFile;
+       /** @var string|null */
        protected $sslCAPath;
        /** @var string[]|null */
        protected $sslCiphers;
@@ -75,7 +77,8 @@ abstract class DatabaseMysqlBase extends Database {
         *   - useGTIDs : use GTID methods like MASTER_GTID_WAIT() when possible.
         *   - sslKeyPath : path to key file [default: null]
         *   - sslCertPath : path to certificate file [default: null]
-        *   - sslCAPath : parth to certificate authority PEM files [default: null]
+        *   - sslCAFile: path to a single certificate authority PEM file [default: null]
+        *   - sslCAPath : parth to certificate authority PEM directory [default: null]
         *   - sslCiphers : array list of allowable ciphers [default: null]
         * @param array $params
         */
@@ -87,7 +90,7 @@ abstract class DatabaseMysqlBase extends Database {
                        ? $params['lagDetectionOptions']
                        : [];
                $this->useGTIDs = !empty( $params['useGTIDs' ] );
-               foreach ( [ 'KeyPath', 'CertPath', 'CAPath', 'Ciphers' ] as $name ) {
+               foreach ( [ 'KeyPath', 'CertPath', 'CAFile', 'CAPath', 'Ciphers' ] as $name ) {
                        $var = "ssl{$name}";
                        if ( isset( $params[$var] ) ) {
                                $this->$var = $params[$var];
@@ -527,25 +530,23 @@ abstract class DatabaseMysqlBase extends Database {
        }
 
        public function tableExists( $table, $fname = __METHOD__ ) {
-               $table = $this->tableName( $table, 'raw' );
-               if ( isset( $this->mSessionTempTables[$table] ) ) {
-                       return true; // already known to exist and won't show in SHOW TABLES anyway
-               }
-
                // Split database and table into proper variables as Database::tableName() returns
                // shared tables prefixed with their database, which do not work in SHOW TABLES statements
-               list( $database, $schema, $prefix, $table ) = $this->qualifiedTableComponents( $table );
+               list( $database, , $prefix, $table ) = $this->qualifiedTableComponents( $table );
+               $tableName = "{$prefix}{$table}";
 
-               $table = $prefix . $table;
+               if ( isset( $this->mSessionTempTables[$tableName] ) ) {
+                       return true; // already known to exist and won't show in SHOW TABLES anyway
+               }
 
                // We can't use buildLike() here, because it specifies an escape character
                // other than the backslash, which is the only one supported by SHOW TABLES
-               $encLike = $this->escapeLikeInternal( $table, '\\' );
+               $encLike = $this->escapeLikeInternal( $tableName, '\\' );
 
-               // If the database has been specified (such as for shared tables), add a FROM $database clause
+               // If the database has been specified (such as for shared tables), use "FROM"
                if ( $database !== '' ) {
-                       $database = $this->addIdentifierQuotes( $database );
-                       $query = "SHOW TABLES FROM $database LIKE '$encLike'";
+                       $encDatabase = $this->addIdentifierQuotes( $database );
+                       $query = "SHOW TABLES FROM $encDatabase LIKE '$encLike'";
                } else {
                        $query = "SHOW TABLES LIKE '$encLike'";
                }
@@ -780,6 +781,8 @@ abstract class DatabaseMysqlBase extends Database {
         * @see https://www.percona.com/doc/percona-toolkit/2.1/pt-heartbeat.html
         */
        protected function getHeartbeatData( array $conds ) {
+               // Query time and trip time are not counted
+               $nowUnix = microtime( true );
                // Do not bother starting implicit transactions here
                $this->clearFlag( self::DBO_TRX, self::REMEMBER_PRIOR );
                try {
@@ -795,7 +798,7 @@ abstract class DatabaseMysqlBase extends Database {
                        $this->restoreFlags();
                }
 
-               return [ $row ? $row->ts : null, microtime( true ) ];
+               return [ $row ? $row->ts : null, $nowUnix ];
        }
 
        protected function getApproximateLagStatus() {
@@ -991,8 +994,8 @@ abstract class DatabaseMysqlBase extends Database {
        }
 
        /**
-        * @param string $sql
-        * @param string $newLine
+        * @param string &$sql
+        * @param string &$newLine
         * @return bool
         */
        public function streamStatementEnd( &$sql, &$newLine ) {