jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/404523 )

Change subject: Remove support for PHP extension 'mysql' (not mysqli!)
......................................................................


Remove support for PHP extension 'mysql' (not mysqli!)

This PHP extension was deprecated in PHP 5.5 and removed in PHP 7.0.
The newer MySQL driver 'mysqli' is the default driver since MediaWiki
1.22 and 'mysql' was deprecated in MediaWiki 1.30.

Bug: T120333
Change-Id: Icff7a63ab47ae1483de87ba6486945974699362b
---
M RELEASE-NOTES-1.31
M autoload.php
M includes/DefaultSettings.php
M includes/installer/MysqlInstaller.php
M includes/libs/rdbms/database/Database.php
D includes/libs/rdbms/database/DatabaseMysql.php
M tests/phpunit/includes/libs/rdbms/database/DatabaseMysqlBaseTest.php
7 files changed, 9 insertions(+), 218 deletions(-)

Approvals:
  MaxSem: Looks good to me, approved
  jenkins-bot: Verified
  Jforrester: Looks good to me, but someone else must approve



diff --git a/RELEASE-NOTES-1.31 b/RELEASE-NOTES-1.31
index 307a8b5..695b88f 100644
--- a/RELEASE-NOTES-1.31
+++ b/RELEASE-NOTES-1.31
@@ -171,6 +171,9 @@
 * The HtmlFormatter class was removed (deprecated in 1.27). The namespaced
   HtmlFormatter\HtmlFormatter class should be used instead.
 * License::getLicenses has been deprecated; use License::getLines instead.
+* The driver 'mysql' for MySQL, deprecated in MediaWiki 1.30, has been removed.
+  The driver has been deprecated since PHP 5.5 and was removed in PHP 7.0. The
+  default driver for MySQL has been 'mysqli' since MediaWiki 1.22.
 
 == Compatibility ==
 MediaWiki 1.31 requires PHP 5.5.9 or later. Although HHVM 3.18.5 or later is 
supported,
diff --git a/autoload.php b/autoload.php
index 5d6104c..cc35dc3 100644
--- a/autoload.php
+++ b/autoload.php
@@ -345,7 +345,6 @@
        'DatabaseLag' => __DIR__ . '/maintenance/lag.php',
        'DatabaseLogEntry' => __DIR__ . '/includes/logging/LogEntry.php',
        'DatabaseMssql' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMssql.php',
-       'DatabaseMysql' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysql.php',
        'DatabaseMysqlBase' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysqlBase.php',
        'DatabaseMysqli' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysqli.php',
        'DatabaseOracle' => __DIR__ . '/includes/db/DatabaseOracle.php',
@@ -1673,7 +1672,6 @@
        'Wikimedia\\Rdbms\\Database' => __DIR__ . 
'/includes/libs/rdbms/database/Database.php',
        'Wikimedia\\Rdbms\\DatabaseDomain' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseDomain.php',
        'Wikimedia\\Rdbms\\DatabaseMssql' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMssql.php',
-       'Wikimedia\\Rdbms\\DatabaseMysql' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysql.php',
        'Wikimedia\\Rdbms\\DatabaseMysqlBase' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysqlBase.php',
        'Wikimedia\\Rdbms\\DatabaseMysqli' => __DIR__ . 
'/includes/libs/rdbms/database/DatabaseMysqli.php',
        'Wikimedia\\Rdbms\\DatabasePostgres' => __DIR__ . 
'/includes/libs/rdbms/database/DatabasePostgres.php',
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index ab01c5f..9208dec 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -1940,6 +1940,7 @@
  *   - user:        DB user
  *   - password:    DB password
  *   - type:        DB type
+ *   - driver:      DB driver (when there are multiple drivers)
  *
  *   - load:        Ratio of DB_REPLICA load, must be >=0, the sum of all 
loads must be >0.
  *                  If this is zero for any given server, no normal query 
traffic will be
diff --git a/includes/installer/MysqlInstaller.php 
b/includes/installer/MysqlInstaller.php
index ab5701a..6256204 100644
--- a/includes/installer/MysqlInstaller.php
+++ b/includes/installer/MysqlInstaller.php
@@ -73,7 +73,7 @@
         * @return bool
         */
        public function isCompiled() {
-               return self::checkExtension( 'mysql' ) || self::checkExtension( 
'mysqli' );
+               return self::checkExtension( 'mysqli' );
        }
 
        /**
diff --git a/includes/libs/rdbms/database/Database.php 
b/includes/libs/rdbms/database/Database.php
index 2eb5c54..323c147 100644
--- a/includes/libs/rdbms/database/Database.php
+++ b/includes/libs/rdbms/database/Database.php
@@ -317,8 +317,8 @@
         *   - flags : Optional bitfield of DBO_* constants that define 
connection, protocol,
         *      buffering, and transaction behavior. It is STRONGLY adviced to 
leave the DBO_DEFAULT
         *      flag in place UNLESS this this database simply acts as a 
key/value store.
-        *   - driver: Optional name of a specific DB client driver. For MySQL, 
there is the old
-        *      'mysql' driver and the newer 'mysqli' driver.
+        *   - driver: Optional name of a specific DB client driver. For MySQL, 
there is only the
+        *      'mysqli' driver; the old one 'mysql' has been removed.
         *   - variables: Optional map of session variables to set after 
connecting. This can be
         *      used to adjust lock timeouts or encoding modes and the like.
         *   - connLogger: Optional PSR-3 logger interface instance.
@@ -337,7 +337,7 @@
         */
        final public static function factory( $dbType, $p = [] ) {
                static $canonicalDBTypes = [
-                       'mysql' => [ 'mysqli', 'mysql' ],
+                       'mysql' => [ 'mysqli' ],
                        'postgres' => [],
                        'sqlite' => [],
                        'oracle' => [],
@@ -345,7 +345,6 @@
                ];
                static $classAliases = [
                        'DatabaseMssql' => DatabaseMssql::class,
-                       'DatabaseMysql' => DatabaseMysql::class,
                        'DatabaseMysqli' => DatabaseMysqli::class,
                        'DatabaseSqlite' => DatabaseSqlite::class,
                        'DatabasePostgres' => DatabasePostgres::class
diff --git a/includes/libs/rdbms/database/DatabaseMysql.php 
b/includes/libs/rdbms/database/DatabaseMysql.php
deleted file mode 100644
index 58b0926..0000000
--- a/includes/libs/rdbms/database/DatabaseMysql.php
+++ /dev/null
@@ -1,210 +0,0 @@
-<?php
-/**
- * This is the MySQL database abstraction layer.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Database
- */
-namespace Wikimedia\Rdbms;
-
-/**
- * Database abstraction object for PHP extension mysql.
- *
- * @deprecated 1.30 PHP extension 'mysql' was deprecated in PHP 5.5 and 
removed in PHP 7.0.
- * @see PHP extension 'mysqli' and DatabaseMysqli
- *
- * @ingroup Database
- * @see Database
- */
-class DatabaseMysql extends DatabaseMysqlBase {
-       /**
-        * @param string $sql
-        * @return resource False on error
-        */
-       protected function doQuery( $sql ) {
-               $conn = $this->getBindingHandle();
-
-               if ( $this->bufferResults() ) {
-                       $ret = mysql_query( $sql, $conn );
-               } else {
-                       $ret = mysql_unbuffered_query( $sql, $conn );
-               }
-
-               return $ret;
-       }
-
-       /**
-        * @param string $realServer
-        * @return bool|resource MySQL Database connection or false on failure 
to connect
-        * @throws DBConnectionError
-        */
-       protected function mysqlConnect( $realServer ) {
-               # Avoid a suppressed fatal error, which is very hard to track 
down
-               if ( !extension_loaded( 'mysql' ) ) {
-                       throw new DBConnectionError(
-                               $this,
-                               "MySQL functions missing, have you compiled PHP 
with the --with-mysql option?\n"
-                       );
-               }
-
-               $connFlags = 0;
-               if ( $this->mFlags & self::DBO_SSL ) {
-                       $connFlags |= MYSQL_CLIENT_SSL;
-               }
-               if ( $this->mFlags & self::DBO_COMPRESS ) {
-                       $connFlags |= MYSQL_CLIENT_COMPRESS;
-               }
-
-               if ( ini_get( 'mysql.connect_timeout' ) <= 3 ) {
-                       $numAttempts = 2;
-               } else {
-                       $numAttempts = 1;
-               }
-
-               $conn = false;
-
-               # The kernel's default SYN retransmission period is far too 
slow for us,
-               # so we use a short timeout plus a manual retry. Retrying means 
that a small
-               # but finite rate of SYN packet loss won't cause user-visible 
errors.
-               for ( $i = 0; $i < $numAttempts && !$conn; $i++ ) {
-                       if ( $i > 1 ) {
-                               usleep( 1000 );
-                       }
-                       if ( $this->mFlags & self::DBO_PERSISTENT ) {
-                               $conn = mysql_pconnect( $realServer, 
$this->mUser, $this->mPassword, $connFlags );
-                       } else {
-                               # Create a new connection...
-                               $conn = mysql_connect( $realServer, 
$this->mUser, $this->mPassword, true, $connFlags );
-                       }
-               }
-
-               return $conn;
-       }
-
-       /**
-        * @param string $charset
-        * @return bool
-        */
-       protected function mysqlSetCharset( $charset ) {
-               $conn = $this->getBindingHandle();
-
-               if ( function_exists( 'mysql_set_charset' ) ) {
-                       return mysql_set_charset( $charset, $conn );
-               } else {
-                       return $this->query( 'SET NAMES ' . $charset, 
__METHOD__ );
-               }
-       }
-
-       /**
-        * @return bool
-        */
-       protected function closeConnection() {
-               $conn = $this->getBindingHandle();
-
-               return mysql_close( $conn );
-       }
-
-       /**
-        * @return int
-        */
-       function insertId() {
-               $conn = $this->getBindingHandle();
-
-               return mysql_insert_id( $conn );
-       }
-
-       /**
-        * @return int
-        */
-       function lastErrno() {
-               if ( $this->mConn ) {
-                       return mysql_errno( $this->mConn );
-               } else {
-                       return mysql_errno();
-               }
-       }
-
-       /**
-        * @return int
-        */
-       function affectedRows() {
-               $conn = $this->getBindingHandle();
-
-               return mysql_affected_rows( $conn );
-       }
-
-       /**
-        * @param string $db
-        * @return bool
-        */
-       function selectDB( $db ) {
-               $conn = $this->getBindingHandle();
-
-               $this->mDBname = $db;
-
-               return mysql_select_db( $db, $conn );
-       }
-
-       protected function mysqlFreeResult( $res ) {
-               return mysql_free_result( $res );
-       }
-
-       protected function mysqlFetchObject( $res ) {
-               return mysql_fetch_object( $res );
-       }
-
-       protected function mysqlFetchArray( $res ) {
-               return mysql_fetch_array( $res );
-       }
-
-       protected function mysqlNumRows( $res ) {
-               return mysql_num_rows( $res );
-       }
-
-       protected function mysqlNumFields( $res ) {
-               return mysql_num_fields( $res );
-       }
-
-       protected function mysqlFetchField( $res, $n ) {
-               return mysql_fetch_field( $res, $n );
-       }
-
-       protected function mysqlFieldName( $res, $n ) {
-               return mysql_field_name( $res, $n );
-       }
-
-       protected function mysqlFieldType( $res, $n ) {
-               return mysql_field_type( $res, $n );
-       }
-
-       protected function mysqlDataSeek( $res, $row ) {
-               return mysql_data_seek( $res, $row );
-       }
-
-       protected function mysqlError( $conn = null ) {
-               return ( $conn !== null ) ? mysql_error( $conn ) : 
mysql_error(); // avoid warning
-       }
-
-       protected function mysqlRealEscapeString( $s ) {
-               $conn = $this->getBindingHandle();
-
-               return mysql_real_escape_string( (string)$s, $conn );
-       }
-}
-
-class_alias( DatabaseMysql::class, 'DatabaseMysql' );
diff --git 
a/tests/phpunit/includes/libs/rdbms/database/DatabaseMysqlBaseTest.php 
b/tests/phpunit/includes/libs/rdbms/database/DatabaseMysqlBaseTest.php
index a9f1880..5e59cfd 100644
--- a/tests/phpunit/includes/libs/rdbms/database/DatabaseMysqlBaseTest.php
+++ b/tests/phpunit/includes/libs/rdbms/database/DatabaseMysqlBaseTest.php
@@ -52,7 +52,7 @@
        protected function doQuery( $sql ) {
        }
 
-       // From DatabaseMysql
+       // From DatabaseMysqli
        protected function mysqlConnect( $realServer ) {
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/404523
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Icff7a63ab47ae1483de87ba6486945974699362b
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Seb35 <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: Seb35 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to