<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[56475] trunk: Database: Remove support for the `mysql` extension.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/56475">56475</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/56475","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>johnbillion</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-08-26 13:01:05 +0000 (Sat, 26 Aug 2023)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Database: Remove support for the `mysql` extension.
The `mysql` extension is no longer used in PHP 7 or above. There's a good amount of conditional code in `wpdb` and the health checks that can be removed now that only the `mysqli` functions are used.
Fixes <a href="https://core.trac.wordpress.org/ticket/59118">#59118</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkphpcompatxmldist">trunk/phpcompat.xml.dist</a></li>
<li><a href="#trunksrcwpadminincludesclasswpdebugdataphp">trunk/src/wp-admin/includes/class-wp-debug-data.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswpsitehealthphp">trunk/src/wp-admin/includes/class-wp-site-health.php</a></li>
<li><a href="#trunksrcwpincludesclasswpdbphp">trunk/src/wp-includes/class-wpdb.php</a></li>
<li><a href="#trunksrcwpincludesloadphp">trunk/src/wp-includes/load.php</a></li>
<li><a href="#trunktestsphpunitincludesutilsphp">trunk/tests/phpunit/includes/utils.php</a></li>
<li><a href="#trunktestsphpunittestsdbphp">trunk/tests/phpunit/tests/db.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkphpcompatxmldist"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/phpcompat.xml.dist</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/phpcompat.xml.dist 2023-08-26 04:47:09 UTC (rev 56474)
+++ trunk/phpcompat.xml.dist 2023-08-26 13:01:05 UTC (rev 56475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -81,9 +81,4 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <rule ref="PHPCompatibility.FunctionUse.RemovedFunctions.mcrypt_create_ivDeprecatedRemoved">
</span><span class="cx" style="display: block; padding: 0 10px"> <exclude-pattern>/random_compat/random_bytes_mcrypt\.php$</exclude-pattern>
</span><span class="cx" style="display: block; padding: 0 10px"> </rule>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- <!-- Allow the WP DB Class for use of `mysql_` extension in PHP < 7.0. -->
- <rule ref="PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved">
- <exclude-pattern>/src/wp-includes/class-wpdb\.php</exclude-pattern>
- </rule>
</del><span class="cx" style="display: block; padding: 0 10px"> </ruleset>
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpdebugdataphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-debug-data.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-debug-data.php 2023-08-26 04:47:09 UTC (rev 56474)
+++ trunk/src/wp-admin/includes/class-wp-debug-data.php 2023-08-26 13:01:05 UTC (rev 56475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -855,10 +855,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Populate the database debug fields.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_resource( $wpdb->dbh ) ) {
- // Old mysql extension.
- $extension = 'mysql';
- } elseif ( is_object( $wpdb->dbh ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_object( $wpdb->dbh ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // mysqli or PDO.
</span><span class="cx" style="display: block; padding: 0 10px"> $extension = get_class( $wpdb->dbh );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -868,16 +865,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $server = $wpdb->get_var( 'SELECT VERSION()' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) {
- $client_version = $wpdb->dbh->client_info;
- } else {
- // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info,PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved
- if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) {
- $client_version = $matches[0];
- } else {
- $client_version = null;
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $client_version = $wpdb->dbh->client_info;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $info['wp-database']['fields']['extension'] = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'label' => __( 'Extension' ),
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpsitehealthphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-site-health.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-site-health.php 2023-08-26 04:47:09 UTC (rev 56474)
+++ trunk/src/wp-admin/includes/class-wp-site-health.php 2023-08-26 13:01:05 UTC (rev 56475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1356,13 +1356,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $wpdb->use_mysqli ) {
- // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_client_info
- $mysql_client_version = mysqli_get_client_info();
- } else {
- // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info,PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved
- $mysql_client_version = mysql_get_client_info();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_client_info
+ $mysql_client_version = mysqli_get_client_info();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpdbphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wpdb.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wpdb.php 2023-08-26 04:47:09 UTC (rev 56474)
+++ trunk/src/wp-includes/class-wpdb.php 2023-08-26 13:01:05 UTC (rev 56475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -142,9 +142,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Possible values:
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * - For successful SELECT, SHOW, DESCRIBE, or EXPLAIN queries:
- * - `mysqli_result` instance when the `mysqli` driver is in use
- * - `resource` when the older `mysql` driver is in use
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * - `mysqli_result` instance for successful SELECT, SHOW, DESCRIBE, or EXPLAIN queries
</ins><span class="cx" style="display: block; padding: 0 10px"> * - `true` for other query types that were successful
</span><span class="cx" style="display: block; padding: 0 10px"> * - `null` if a query is yet to be made or if the result has since been flushed
</span><span class="cx" style="display: block; padding: 0 10px"> * - `false` if the query returned an error
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -151,7 +149,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 0.71
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @var mysqli_result|resource|bool|null
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var mysqli_result|bool|null
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $result;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -604,14 +602,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Possible values:
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * - `mysqli` instance when the `mysqli` driver is in use
- * - `resource` when the older `mysql` driver is in use
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * - `mysqli` instance during normal operation
</ins><span class="cx" style="display: block; padding: 0 10px"> * - `null` if the connection is yet to be made or has been closed
</span><span class="cx" style="display: block; padding: 0 10px"> * - `false` if the connection has failed
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 0.71
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @var mysqli|resource|false|null
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var mysqli|false|null
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected $dbh;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -694,15 +691,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> private $allow_unsafe_unquoted_parameters = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Whether to use mysqli over mysql. Default false.
- *
- * @since 3.9.0
- *
- * @var bool
- */
- private $use_mysqli = false;
-
- /**
</del><span class="cx" style="display: block; padding: 0 10px"> * Whether we've managed to successfully connect at some point.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.9.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -751,15 +739,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->show_errors();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Use the `mysqli` extension if it exists unless `WP_USE_EXT_MYSQL` is defined as true.
- if ( function_exists( 'mysqli_connect' ) ) {
- $this->use_mysqli = true;
-
- if ( defined( 'WP_USE_EXT_MYSQL' ) ) {
- $this->use_mysqli = ! WP_USE_EXT_MYSQL;
- }
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->dbuser = $dbuser;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->dbpassword = $dbpassword;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->dbname = $dbname;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -880,7 +859,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * }
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function determine_charset( $charset, $collate ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ( $this->use_mysqli && ! ( $this->dbh instanceof mysqli ) ) || empty( $this->dbh ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ( ! ( $this->dbh instanceof mysqli ) ) || empty( $this->dbh ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return compact( 'charset', 'collate' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -915,9 +894,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.1.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param mysqli|resource $dbh The connection returned by `mysqli_connect()` or `mysql_connect()`.
- * @param string $charset Optional. The character set. Default null.
- * @param string $collate Optional. The collation. Default null.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param mysqli $dbh The connection returned by `mysqli_connect()`.
+ * @param string $charset Optional. The character set. Default null.
+ * @param string $collate Optional. The collation. Default null.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function set_charset( $dbh, $charset = null, $collate = null ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $charset ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -929,29 +908,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->has_cap( 'collation' ) && ! empty( $charset ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $set_charset_succeeded = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
- $set_charset_succeeded = mysqli_set_charset( $dbh, $charset );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
+ $set_charset_succeeded = mysqli_set_charset( $dbh, $charset );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $set_charset_succeeded ) {
- $query = $this->prepare( 'SET NAMES %s', $charset );
- if ( ! empty( $collate ) ) {
- $query .= $this->prepare( ' COLLATE %s', $collate );
- }
- mysqli_query( $dbh, $query );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $set_charset_succeeded ) {
+ $query = $this->prepare( 'SET NAMES %s', $charset );
+ if ( ! empty( $collate ) ) {
+ $query .= $this->prepare( ' COLLATE %s', $collate );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else {
- if ( function_exists( 'mysql_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
- $set_charset_succeeded = mysql_set_charset( $charset, $dbh );
- }
- if ( $set_charset_succeeded ) {
- $query = $this->prepare( 'SET NAMES %s', $charset );
- if ( ! empty( $collate ) ) {
- $query .= $this->prepare( ' COLLATE %s', $collate );
- }
- mysql_query( $query, $dbh );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ mysqli_query( $dbh, $query );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -967,26 +933,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function set_sql_mode( $modes = array() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $modes ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- $res = mysqli_query( $this->dbh, 'SELECT @@SESSION.sql_mode' );
- } else {
- $res = mysql_query( 'SELECT @@SESSION.sql_mode', $this->dbh );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $res = mysqli_query( $this->dbh, 'SELECT @@SESSION.sql_mode' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $res ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- $modes_array = mysqli_fetch_array( $res );
- if ( empty( $modes_array[0] ) ) {
- return;
- }
- $modes_str = $modes_array[0];
- } else {
- $modes_str = mysql_result( $res, 0 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $modes_array = mysqli_fetch_array( $res );
+
+ if ( empty( $modes_array[0] ) ) {
+ return;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $modes_str = $modes_array[0];
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $modes_str ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1013,11 +973,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $modes_str = implode( ',', $modes );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- mysqli_query( $this->dbh, "SET SESSION sql_mode='$modes_str'" );
- } else {
- mysql_query( "SET SESSION sql_mode='$modes_str'", $this->dbh );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ mysqli_query( $this->dbh, "SET SESSION sql_mode='$modes_str'" );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1220,9 +1176,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 0.71
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $db Database name.
- * @param mysqli|resource $dbh Optional. Database connection.
- * Defaults to the current database handle.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $db Database name.
+ * @param mysqli $dbh Optional. Database connection.
+ * Defaults to the current database handle.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function select( $db, $dbh = null ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_null( $dbh ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1229,11 +1185,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $dbh = $this->dbh;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- $success = mysqli_select_db( $dbh, $db );
- } else {
- $success = mysql_select_db( $db, $dbh );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $success = mysqli_select_db( $dbh, $db );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $success ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->ready = false;
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! did_action( 'template_redirect' ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1297,12 +1250,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Real escape, using mysqli_real_escape_string() or mysql_real_escape_string().
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Real escape using mysqli_real_escape_string().
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.8.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see mysqli_real_escape_string()
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @see mysql_real_escape_string()
</del><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $data String to escape.
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string Escaped string.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1313,11 +1265,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->dbh ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- $escaped = mysqli_real_escape_string( $this->dbh, $data );
- } else {
- $escaped = mysql_real_escape_string( $data, $this->dbh );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $escaped = mysqli_real_escape_string( $this->dbh, $data );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $class = get_class( $this );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1836,12 +1784,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> global $EZSQL_ERROR;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $str ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- $str = mysqli_error( $this->dbh );
- } else {
- $str = mysql_error( $this->dbh );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $str = mysqli_error( $this->dbh );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $EZSQL_ERROR[] = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'query' => $this->last_query,
</span><span class="cx" style="display: block; padding: 0 10px"> 'error_str' => $str,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1963,7 +1908,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->num_rows = 0;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->last_error = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli && $this->result instanceof mysqli_result ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->result instanceof mysqli_result ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> mysqli_free_result( $this->result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->result = null;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1976,8 +1921,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> while ( mysqli_more_results( $this->dbh ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> mysqli_next_result( $this->dbh );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ( is_resource( $this->result ) ) {
- mysql_free_result( $this->result );
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1995,82 +1938,47 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function db_connect( $allow_bail = true ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->is_mysql = true;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /*
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Deprecated in 3.9+ when using MySQLi. No equivalent
- * $new_link parameter exists for mysqli_* functions.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Set the MySQLi error reporting off because WordPress handles its own.
+ * This is due to the default value change from `MYSQLI_REPORT_OFF`
+ * to `MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT` in PHP 8.1.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $new_link = defined( 'MYSQL_NEW_LINK' ) ? MYSQL_NEW_LINK : true;
- $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ mysqli_report( MYSQLI_REPORT_OFF );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- /*
- * Set the MySQLi error reporting off because WordPress handles its own.
- * This is due to the default value change from `MYSQLI_REPORT_OFF`
- * to `MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT` in PHP 8.1.
- */
- mysqli_report( MYSQLI_REPORT_OFF );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->dbh = mysqli_init();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->dbh = mysqli_init();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $host = $this->dbhost;
+ $port = null;
+ $socket = null;
+ $is_ipv6 = false;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $host = $this->dbhost;
- $port = null;
- $socket = null;
- $is_ipv6 = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $host_data = $this->parse_db_host( $this->dbhost );
+ if ( $host_data ) {
+ list( $host, $port, $socket, $is_ipv6 ) = $host_data;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $host_data = $this->parse_db_host( $this->dbhost );
- if ( $host_data ) {
- list( $host, $port, $socket, $is_ipv6 ) = $host_data;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /*
+ * If using the `mysqlnd` library, the IPv6 address needs to be enclosed
+ * in square brackets, whereas it doesn't while using the `libmysqlclient` library.
+ * @see https://bugs.php.net/bug.php?id=67563
+ */
+ if ( $is_ipv6 && extension_loaded( 'mysqlnd' ) ) {
+ $host = "[$host]";
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /*
- * If using the `mysqlnd` library, the IPv6 address needs to be enclosed
- * in square brackets, whereas it doesn't while using the `libmysqlclient` library.
- * @see https://bugs.php.net/bug.php?id=67563
- */
- if ( $is_ipv6 && extension_loaded( 'mysqlnd' ) ) {
- $host = "[$host]";
- }
-
- if ( WP_DEBUG ) {
- mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
- } else {
- // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
- @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
- }
-
- if ( $this->dbh->connect_errno ) {
- $this->dbh = null;
-
- /*
- * It's possible ext/mysqli is misconfigured. Fall back to ext/mysql if:
- * - We haven't previously connected, and
- * - WP_USE_EXT_MYSQL isn't set to false, and
- * - ext/mysql is loaded.
- */
- $attempt_fallback = true;
-
- if ( $this->has_connected ) {
- $attempt_fallback = false;
- } elseif ( defined( 'WP_USE_EXT_MYSQL' ) && ! WP_USE_EXT_MYSQL ) {
- $attempt_fallback = false;
- } elseif ( ! function_exists( 'mysql_connect' ) ) {
- $attempt_fallback = false;
- }
-
- if ( $attempt_fallback ) {
- $this->use_mysqli = false;
- return $this->db_connect( $allow_bail );
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( WP_DEBUG ) {
+ mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( WP_DEBUG ) {
- $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
- } else {
- // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
- $this->dbh = @mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
+ @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->dbh->connect_errno ) {
+ $this->dbh = null;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->dbh && $allow_bail ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_load_translations_early();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2196,14 +2104,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool|void True if the connection is up.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function check_connection( $allow_bail = true ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- if ( ! empty( $this->dbh ) && mysqli_ping( $this->dbh ) ) {
- return true;
- }
- } else {
- if ( ! empty( $this->dbh ) && mysql_ping( $this->dbh ) ) {
- return true;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $this->dbh ) && mysqli_ping( $this->dbh ) ) {
+ return true;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $error_reporting = false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2347,24 +2249,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Database server has gone away, try to reconnect.
</span><span class="cx" style="display: block; padding: 0 10px"> $mysql_errno = 0;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! empty( $this->dbh ) ) {
- if ( $this->use_mysqli ) {
- if ( $this->dbh instanceof mysqli ) {
- $mysql_errno = mysqli_errno( $this->dbh );
- } else {
- /*
- * $dbh is defined, but isn't a real connection.
- * Something has gone horribly wrong, let's try a reconnect.
- */
- $mysql_errno = 2006;
- }
- } else {
- if ( is_resource( $this->dbh ) ) {
- $mysql_errno = mysql_errno( $this->dbh );
- } else {
- $mysql_errno = 2006;
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( $this->dbh instanceof mysqli ) {
+ $mysql_errno = mysqli_errno( $this->dbh );
+ } else {
+ /*
+ * $dbh is defined, but isn't a real connection.
+ * Something has gone horribly wrong, let's try a reconnect.
+ */
+ $mysql_errno = 2006;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $this->dbh ) || 2006 === $mysql_errno ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2377,18 +2270,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // If there is an error then take note of it.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- if ( $this->dbh instanceof mysqli ) {
- $this->last_error = mysqli_error( $this->dbh );
- } else {
- $this->last_error = __( 'Unable to retrieve the error message from MySQL' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->dbh instanceof mysqli ) {
+ $this->last_error = mysqli_error( $this->dbh );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_resource( $this->dbh ) ) {
- $this->last_error = mysql_error( $this->dbh );
- } else {
- $this->last_error = __( 'Unable to retrieve the error message from MySQL' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->last_error = __( 'Unable to retrieve the error message from MySQL' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->last_error ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2404,33 +2289,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( preg_match( '/^\s*(create|alter|truncate|drop)\s/i', $query ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $return_val = $this->result;
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif ( preg_match( '/^\s*(insert|delete|update|replace)\s/i', $query ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- $this->rows_affected = mysqli_affected_rows( $this->dbh );
- } else {
- $this->rows_affected = mysql_affected_rows( $this->dbh );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->rows_affected = mysqli_affected_rows( $this->dbh );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Take note of the insert_id.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( preg_match( '/^\s*(insert|replace)\s/i', $query ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- $this->insert_id = mysqli_insert_id( $this->dbh );
- } else {
- $this->insert_id = mysql_insert_id( $this->dbh );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->insert_id = mysqli_insert_id( $this->dbh );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Return number of rows affected.
</span><span class="cx" style="display: block; padding: 0 10px"> $return_val = $this->rows_affected;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $num_rows = 0;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli && $this->result instanceof mysqli_result ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( $this->result instanceof mysqli_result ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> while ( $row = mysqli_fetch_object( $this->result ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->last_result[ $num_rows ] = $row;
</span><span class="cx" style="display: block; padding: 0 10px"> $num_rows++;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ( is_resource( $this->result ) ) {
- while ( $row = mysql_fetch_object( $this->result ) ) {
- $this->last_result[ $num_rows ] = $row;
- $num_rows++;
- }
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Log and return the number of rows selected.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2442,7 +2317,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Internal function to perform the mysql_query() call.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Internal function to perform the mysqli_query() call.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.9.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2455,11 +2330,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->timer_start();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! empty( $this->dbh ) && $this->use_mysqli ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $this->dbh ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->result = mysqli_query( $this->dbh, $query );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } elseif ( ! empty( $this->dbh ) ) {
- $this->result = mysql_query( $query, $this->dbh );
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->num_queries++;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3636,11 +3510,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->charset ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $connection_charset = $this->charset;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- $connection_charset = mysqli_character_set_name( $this->dbh );
- } else {
- $connection_charset = mysql_client_encoding();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $connection_charset = mysqli_character_set_name( $this->dbh );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $value['length'] ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3850,16 +3720,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- $num_fields = mysqli_num_fields( $this->result );
- for ( $i = 0; $i < $num_fields; $i++ ) {
- $this->col_info[ $i ] = mysqli_fetch_field( $this->result );
- }
- } else {
- $num_fields = mysql_num_fields( $this->result );
- for ( $i = 0; $i < $num_fields; $i++ ) {
- $this->col_info[ $i ] = mysql_fetch_field( $this->result, $i );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $num_fields = mysqli_num_fields( $this->result );
+
+ for ( $i = 0; $i < $num_fields; $i++ ) {
+ $this->col_info[ $i ] = mysqli_fetch_field( $this->result );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3932,18 +3796,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->show_errors ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $error = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- if ( $this->dbh instanceof mysqli ) {
- $error = mysqli_error( $this->dbh );
- } elseif ( mysqli_connect_errno() ) {
- $error = mysqli_connect_error();
- }
- } else {
- if ( is_resource( $this->dbh ) ) {
- $error = mysql_error( $this->dbh );
- } else {
- $error = mysql_error();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->dbh instanceof mysqli ) {
+ $error = mysqli_error( $this->dbh );
+ } elseif ( mysqli_connect_errno() ) {
+ $error = mysqli_connect_error();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $error ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3975,11 +3831,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- $closed = mysqli_close( $this->dbh );
- } else {
- $closed = mysql_close( $this->dbh );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $closed = mysqli_close( $this->dbh );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $closed ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->dbh = null;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4098,12 +3950,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( version_compare( $db_version, '5.5.3', '<' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- $client_version = mysqli_get_client_info();
- } else {
- $client_version = mysql_get_client_info();
- }
</del><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $client_version = mysqli_get_client_info();
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
</span><span class="cx" style="display: block; padding: 0 10px"> * mysqlnd has supported utf8mb4 since 5.0.9.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4154,19 +4003,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Retrieves full database server information.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns the version of the MySQL server.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string|false Server info on success, false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string Server version as a string.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function db_server_info() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $this->use_mysqli ) {
- $server_info = mysqli_get_server_info( $this->dbh );
- } else {
- $server_info = mysql_get_server_info( $this->dbh );
- }
-
- return $server_info;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return mysqli_get_server_info( $this->dbh );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesloadphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/load.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/load.php 2023-08-26 04:47:09 UTC (rev 56474)
+++ trunk/src/wp-includes/load.php 2023-08-26 13:01:05 UTC (rev 56475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -134,7 +134,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Checks for the required PHP version, and the MySQL extension or
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks for the required PHP version, and the mysqli extension or
</ins><span class="cx" style="display: block; padding: 0 10px"> * a database drop-in.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Dies if requirements are not met.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -166,7 +166,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // This runs before default constants are defined, so we can't assume WP_CONTENT_DIR is set yet.
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_content_dir = defined( 'WP_CONTENT_DIR' ) ? WP_CONTENT_DIR : ABSPATH . 'wp-content';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! function_exists( 'mysqli_connect' ) && ! function_exists( 'mysql_connect' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! function_exists( 'mysqli_connect' )
</ins><span class="cx" style="display: block; padding: 0 10px"> && ! file_exists( $wp_content_dir . '/db.php' )
</span><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> require_once ABSPATH . WPINC . '/functions.php';
</span></span></pre></div>
<a id="trunktestsphpunitincludesutilsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/includes/utils.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/includes/utils.php 2023-08-26 04:47:09 UTC (rev 56474)
+++ trunk/tests/phpunit/includes/utils.php 2023-08-26 13:01:05 UTC (rev 56475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -556,7 +556,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->dbh = $wpdb->dbh;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->use_mysqli = $wpdb->use_mysqli;
</del><span class="cx" style="display: block; padding: 0 10px"> $this->is_mysql = $wpdb->is_mysql;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->ready = true;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->field_types = $wpdb->field_types;
</span></span></pre></div>
<a id="trunktestsphpunittestsdbphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/db.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/db.php 2023-08-26 04:47:09 UTC (rev 56474)
+++ trunk/tests/phpunit/tests/db.php 2023-08-26 13:01:05 UTC (rev 56475)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -713,9 +713,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_mysqli_flush_sync() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! $wpdb->use_mysqli ) {
- $this->markTestSkipped( 'mysqli not being used.' );
- }
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $suppress = $wpdb->suppress_errors( true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre>
</div>
</div>
</body>
</html>