update wordpress dependency files for WP 6.4.1

This commit is contained in:
Matthew Bucci
2023-11-08 22:48:27 -08:00
parent a810cfb7da
commit e3f3682bc0
4 changed files with 341 additions and 353 deletions

View File

@ -3,7 +3,7 @@
Plugin Name: PostgreSQL for WordPress (PG4WP) Plugin Name: PostgreSQL for WordPress (PG4WP)
Plugin URI: https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress Plugin URI: https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress
Description: PG4WP is a special plugin enabling WordPress to use a PostgreSQL database. Description: PG4WP is a special plugin enabling WordPress to use a PostgreSQL database.
Version: v2.2 Version: v3.0.0
Author: PostgreSQL-For-Wordpress Author: PostgreSQL-For-Wordpress
Author URI: https://github.com/PostgreSQL-For-Wordpress Author URI: https://github.com/PostgreSQL-For-Wordpress
License: GPLv2 or newer. License: GPLv2 or newer.

View File

@ -142,16 +142,14 @@ class wpdb {
* *
* Possible values: * Possible values:
* *
* - For successful SELECT, SHOW, DESCRIBE, or EXPLAIN queries: * - `mysqli_result` instance 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
* - `true` for other query types that were successful * - `true` for other query types that were successful
* - `null` if a query is yet to be made or if the result has since been flushed * - `null` if a query is yet to be made or if the result has since been flushed
* - `false` if the query returned an error * - `false` if the query returned an error
* *
* @since 0.71 * @since 0.71
* *
* @var mysqli_result|resource|bool|null * @var mysqli_result|bool|null
*/ */
protected $result; protected $result;
@ -604,14 +602,13 @@ class wpdb {
* *
* Possible values: * Possible values:
* *
* - `mysqli` instance when the `mysqli` driver is in use * - `mysqli` instance during normal operation
* - `resource` when the older `mysql` driver is in use
* - `null` if the connection is yet to be made or has been closed * - `null` if the connection is yet to be made or has been closed
* - `false` if the connection has failed * - `false` if the connection has failed
* *
* @since 0.71 * @since 0.71
* *
* @var mysqli|resource|false|null * @var mysqli|false|null
*/ */
protected $dbh; protected $dbh;
@ -694,13 +691,19 @@ class wpdb {
private $allow_unsafe_unquoted_parameters = true; private $allow_unsafe_unquoted_parameters = true;
/** /**
* Whether to use mysqli over mysql. Default false. * Whether to use the mysqli extension over mysql. This is no longer used as the mysql
* extension is no longer supported.
*
* Default true.
* *
* @since 3.9.0 * @since 3.9.0
* @since 6.4.0 This property was removed.
* @since 6.4.1 This property was reinstated and its default value was changed to true.
* The property is no longer used in core but may be accessed externally.
* *
* @var bool * @var bool
*/ */
private $use_mysqli = false; private $use_mysqli = true;
/** /**
* Whether we've managed to successfully connect at some point. * Whether we've managed to successfully connect at some point.
@ -751,15 +754,6 @@ class wpdb {
$this->show_errors(); $this->show_errors();
} }
// 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;
}
}
$this->dbuser = $dbuser; $this->dbuser = $dbuser;
$this->dbpassword = $dbpassword; $this->dbpassword = $dbpassword;
$this->dbname = $dbname; $this->dbname = $dbname;
@ -880,7 +874,7 @@ class wpdb {
* } * }
*/ */
public function determine_charset( $charset, $collate ) { public function determine_charset( $charset, $collate ) {
if ( ( $this->use_mysqli && ! ( $this->dbh instanceof mysqli ) ) || empty( $this->dbh ) ) { if ( ( ! ( $this->dbh instanceof mysqli ) ) || empty( $this->dbh ) ) {
return compact( 'charset', 'collate' ); return compact( 'charset', 'collate' );
} }
@ -915,7 +909,7 @@ class wpdb {
* *
* @since 3.1.0 * @since 3.1.0
* *
* @param mysqli|resource $dbh The connection returned by `mysqli_connect()` or `mysql_connect()`. * @param mysqli $dbh The connection returned by `mysqli_connect()`.
* @param string $charset Optional. The character set. Default null. * @param string $charset Optional. The character set. Default null.
* @param string $collate Optional. The collation. Default null. * @param string $collate Optional. The collation. Default null.
*/ */
@ -929,7 +923,6 @@ class wpdb {
if ( $this->has_cap( 'collation' ) && ! empty( $charset ) ) { if ( $this->has_cap( 'collation' ) && ! empty( $charset ) ) {
$set_charset_succeeded = true; $set_charset_succeeded = true;
if ( $this->use_mysqli ) {
if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) { if ( function_exists( 'mysqli_set_charset' ) && $this->has_cap( 'set_charset' ) ) {
$set_charset_succeeded = mysqli_set_charset( $dbh, $charset ); $set_charset_succeeded = mysqli_set_charset( $dbh, $charset );
} }
@ -941,18 +934,6 @@ class wpdb {
} }
mysqli_query( $dbh, $query ); mysqli_query( $dbh, $query );
} }
} 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 );
}
}
} }
} }
@ -967,25 +948,19 @@ class wpdb {
*/ */
public function set_sql_mode( $modes = array() ) { public function set_sql_mode( $modes = array() ) {
if ( empty( $modes ) ) { if ( empty( $modes ) ) {
if ( $this->use_mysqli ) {
$res = mysqli_query( $this->dbh, 'SELECT @@SESSION.sql_mode' ); $res = mysqli_query( $this->dbh, 'SELECT @@SESSION.sql_mode' );
} else {
$res = mysql_query( 'SELECT @@SESSION.sql_mode', $this->dbh );
}
if ( empty( $res ) ) { if ( empty( $res ) ) {
return; return;
} }
if ( $this->use_mysqli ) {
$modes_array = mysqli_fetch_array( $res ); $modes_array = mysqli_fetch_array( $res );
if ( empty( $modes_array[0] ) ) { if ( empty( $modes_array[0] ) ) {
return; return;
} }
$modes_str = $modes_array[0]; $modes_str = $modes_array[0];
} else {
$modes_str = mysql_result( $res, 0 );
}
if ( empty( $modes_str ) ) { if ( empty( $modes_str ) ) {
return; return;
@ -1013,11 +988,7 @@ class wpdb {
$modes_str = implode( ',', $modes ); $modes_str = implode( ',', $modes );
if ( $this->use_mysqli ) {
mysqli_query( $this->dbh, "SET SESSION sql_mode='$modes_str'" ); mysqli_query( $this->dbh, "SET SESSION sql_mode='$modes_str'" );
} else {
mysql_query( "SET SESSION sql_mode='$modes_str'", $this->dbh );
}
} }
/** /**
@ -1221,7 +1192,7 @@ class wpdb {
* @since 0.71 * @since 0.71
* *
* @param string $db Database name. * @param string $db Database name.
* @param mysqli|resource $dbh Optional. Database connection. * @param mysqli $dbh Optional. Database connection.
* Defaults to the current database handle. * Defaults to the current database handle.
*/ */
public function select( $db, $dbh = null ) { public function select( $db, $dbh = null ) {
@ -1229,11 +1200,8 @@ class wpdb {
$dbh = $this->dbh; $dbh = $this->dbh;
} }
if ( $this->use_mysqli ) {
$success = mysqli_select_db( $dbh, $db ); $success = mysqli_select_db( $dbh, $db );
} else {
$success = mysql_select_db( $db, $dbh );
}
if ( ! $success ) { if ( ! $success ) {
$this->ready = false; $this->ready = false;
if ( ! did_action( 'template_redirect' ) ) { if ( ! did_action( 'template_redirect' ) ) {
@ -1297,12 +1265,11 @@ class wpdb {
} }
/** /**
* Real escape, using mysqli_real_escape_string() or mysql_real_escape_string(). * Real escape using mysqli_real_escape_string().
* *
* @since 2.8.0 * @since 2.8.0
* *
* @see mysqli_real_escape_string() * @see mysqli_real_escape_string()
* @see mysql_real_escape_string()
* *
* @param string $data String to escape. * @param string $data String to escape.
* @return string Escaped string. * @return string Escaped string.
@ -1313,11 +1280,7 @@ class wpdb {
} }
if ( $this->dbh ) { if ( $this->dbh ) {
if ( $this->use_mysqli ) {
$escaped = mysqli_real_escape_string( $this->dbh, $data ); $escaped = mysqli_real_escape_string( $this->dbh, $data );
} else {
$escaped = mysql_real_escape_string( $data, $this->dbh );
}
} else { } else {
$class = get_class( $this ); $class = get_class( $this );
@ -1591,7 +1554,7 @@ class wpdb {
$k = 1; $k = 1;
$l = strlen( $s ); $l = strlen( $s );
while ( $k <= $l && '%' === $s[ $l - $k ] ) { while ( $k <= $l && '%' === $s[ $l - $k ] ) {
$k++; ++$k;
} }
$placeholder = '%' . ( $k % 2 ? '%' : '' ) . $format . $type; $placeholder = '%' . ( $k % 2 ? '%' : '' ) . $format . $type;
@ -1652,7 +1615,7 @@ class wpdb {
$new_query .= $split_query[ $key - 2 ] . $split_query[ $key - 1 ] . $placeholder; $new_query .= $split_query[ $key - 2 ] . $split_query[ $key - 1 ] . $placeholder;
$key += 3; $key += 3;
$arg_id++; ++$arg_id;
} }
// Replace $query; and add remaining $query characters, or index 0 if there were no placeholders. // Replace $query; and add remaining $query characters, or index 0 if there were no placeholders.
@ -1684,7 +1647,7 @@ class wpdb {
$used_placeholders[ $arg_pos ][] = $placeholder; $used_placeholders[ $arg_pos ][] = $placeholder;
$key += 3; $key += 3;
$arg_id++; ++$arg_id;
} }
$conflicts = array(); $conflicts = array();
@ -1836,12 +1799,9 @@ class wpdb {
global $EZSQL_ERROR; global $EZSQL_ERROR;
if ( ! $str ) { if ( ! $str ) {
if ( $this->use_mysqli ) {
$str = mysqli_error( $this->dbh ); $str = mysqli_error( $this->dbh );
} else {
$str = mysql_error( $this->dbh );
}
} }
$EZSQL_ERROR[] = array( $EZSQL_ERROR[] = array(
'query' => $this->last_query, 'query' => $this->last_query,
'error_str' => $str, 'error_str' => $str,
@ -1963,7 +1923,7 @@ class wpdb {
$this->num_rows = 0; $this->num_rows = 0;
$this->last_error = ''; $this->last_error = '';
if ( $this->use_mysqli && $this->result instanceof mysqli_result ) { if ( $this->result instanceof mysqli_result ) {
mysqli_free_result( $this->result ); mysqli_free_result( $this->result );
$this->result = null; $this->result = null;
@ -1976,8 +1936,6 @@ class wpdb {
while ( mysqli_more_results( $this->dbh ) ) { while ( mysqli_more_results( $this->dbh ) ) {
mysqli_next_result( $this->dbh ); mysqli_next_result( $this->dbh );
} }
} elseif ( is_resource( $this->result ) ) {
mysql_free_result( $this->result );
} }
} }
@ -1995,14 +1953,8 @@ class wpdb {
public function db_connect( $allow_bail = true ) { public function db_connect( $allow_bail = true ) {
$this->is_mysql = true; $this->is_mysql = true;
/*
* Deprecated in 3.9+ when using MySQLi. No equivalent
* $new_link parameter exists for mysqli_* functions.
*/
$new_link = defined( 'MYSQL_NEW_LINK' ) ? MYSQL_NEW_LINK : true;
$client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0; $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0;
if ( $this->use_mysqli ) {
/* /*
* Set the MySQLi error reporting off because WordPress handles its own. * Set the MySQLi error reporting off because WordPress handles its own.
* This is due to the default value change from `MYSQLI_REPORT_OFF` * This is due to the default value change from `MYSQLI_REPORT_OFF`
@ -2040,35 +1992,6 @@ class wpdb {
if ( $this->dbh->connect_errno ) { if ( $this->dbh->connect_errno ) {
$this->dbh = null; $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 );
}
}
} else {
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 );
}
} }
if ( ! $this->dbh && $allow_bail ) { if ( ! $this->dbh && $allow_bail ) {
@ -2196,15 +2119,9 @@ class wpdb {
* @return bool|void True if the connection is up. * @return bool|void True if the connection is up.
*/ */
public function check_connection( $allow_bail = true ) { public function check_connection( $allow_bail = true ) {
if ( $this->use_mysqli ) {
if ( ! empty( $this->dbh ) && mysqli_ping( $this->dbh ) ) { if ( ! empty( $this->dbh ) && mysqli_ping( $this->dbh ) ) {
return true; return true;
} }
} else {
if ( ! empty( $this->dbh ) && mysql_ping( $this->dbh ) ) {
return true;
}
}
$error_reporting = false; $error_reporting = false;
@ -2347,8 +2264,7 @@ class wpdb {
// Database server has gone away, try to reconnect. // Database server has gone away, try to reconnect.
$mysql_errno = 0; $mysql_errno = 0;
if ( ! empty( $this->dbh ) ) {
if ( $this->use_mysqli ) {
if ( $this->dbh instanceof mysqli ) { if ( $this->dbh instanceof mysqli ) {
$mysql_errno = mysqli_errno( $this->dbh ); $mysql_errno = mysqli_errno( $this->dbh );
} else { } else {
@ -2358,14 +2274,6 @@ class wpdb {
*/ */
$mysql_errno = 2006; $mysql_errno = 2006;
} }
} else {
if ( is_resource( $this->dbh ) ) {
$mysql_errno = mysql_errno( $this->dbh );
} else {
$mysql_errno = 2006;
}
}
}
if ( empty( $this->dbh ) || 2006 === $mysql_errno ) { if ( empty( $this->dbh ) || 2006 === $mysql_errno ) {
if ( $this->check_connection() ) { if ( $this->check_connection() ) {
@ -2377,19 +2285,11 @@ class wpdb {
} }
// If there is an error then take note of it. // If there is an error then take note of it.
if ( $this->use_mysqli ) {
if ( $this->dbh instanceof mysqli ) { if ( $this->dbh instanceof mysqli ) {
$this->last_error = mysqli_error( $this->dbh ); $this->last_error = mysqli_error( $this->dbh );
} else { } else {
$this->last_error = __( 'Unable to retrieve the error message from MySQL' ); $this->last_error = __( 'Unable to retrieve the error message from MySQL' );
} }
} else {
if ( is_resource( $this->dbh ) ) {
$this->last_error = mysql_error( $this->dbh );
} else {
$this->last_error = __( 'Unable to retrieve the error message from MySQL' );
}
}
if ( $this->last_error ) { if ( $this->last_error ) {
// Clear insert_id on a subsequent failed insert. // Clear insert_id on a subsequent failed insert.
@ -2404,32 +2304,22 @@ class wpdb {
if ( preg_match( '/^\s*(create|alter|truncate|drop)\s/i', $query ) ) { if ( preg_match( '/^\s*(create|alter|truncate|drop)\s/i', $query ) ) {
$return_val = $this->result; $return_val = $this->result;
} elseif ( preg_match( '/^\s*(insert|delete|update|replace)\s/i', $query ) ) { } elseif ( preg_match( '/^\s*(insert|delete|update|replace)\s/i', $query ) ) {
if ( $this->use_mysqli ) {
$this->rows_affected = mysqli_affected_rows( $this->dbh ); $this->rows_affected = mysqli_affected_rows( $this->dbh );
} else {
$this->rows_affected = mysql_affected_rows( $this->dbh );
}
// Take note of the insert_id. // Take note of the insert_id.
if ( preg_match( '/^\s*(insert|replace)\s/i', $query ) ) { if ( preg_match( '/^\s*(insert|replace)\s/i', $query ) ) {
if ( $this->use_mysqli ) {
$this->insert_id = mysqli_insert_id( $this->dbh ); $this->insert_id = mysqli_insert_id( $this->dbh );
} else {
$this->insert_id = mysql_insert_id( $this->dbh );
}
} }
// Return number of rows affected. // Return number of rows affected.
$return_val = $this->rows_affected; $return_val = $this->rows_affected;
} else { } else {
$num_rows = 0; $num_rows = 0;
if ( $this->use_mysqli && $this->result instanceof mysqli_result ) {
if ( $this->result instanceof mysqli_result ) {
while ( $row = mysqli_fetch_object( $this->result ) ) { while ( $row = mysqli_fetch_object( $this->result ) ) {
$this->last_result[ $num_rows ] = $row; $this->last_result[ $num_rows ] = $row;
$num_rows++; ++$num_rows;
}
} elseif ( is_resource( $this->result ) ) {
while ( $row = mysql_fetch_object( $this->result ) ) {
$this->last_result[ $num_rows ] = $row;
$num_rows++;
} }
} }
@ -2442,7 +2332,7 @@ class wpdb {
} }
/** /**
* Internal function to perform the mysql_query() call. * Internal function to perform the mysqli_query() call.
* *
* @since 3.9.0 * @since 3.9.0
* *
@ -2455,12 +2345,11 @@ class wpdb {
$this->timer_start(); $this->timer_start();
} }
if ( ! empty( $this->dbh ) && $this->use_mysqli ) { if ( ! empty( $this->dbh ) ) {
$this->result = mysqli_query( $this->dbh, $query ); $this->result = mysqli_query( $this->dbh, $query );
} elseif ( ! empty( $this->dbh ) ) {
$this->result = mysql_query( $query, $this->dbh );
} }
$this->num_queries++;
++$this->num_queries;
if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
$this->log_query( $this->log_query(
@ -2573,8 +2462,24 @@ class wpdb {
* *
* Examples: * Examples:
* *
* wpdb::insert( 'table', array( 'column' => 'foo', 'field' => 'bar' ) ) * $wpdb->insert(
* wpdb::insert( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( '%s', '%d' ) ) * 'table',
* array(
* 'column1' => 'foo',
* 'column2' => 'bar',
* )
* );
* $wpdb->insert(
* 'table',
* array(
* 'column1' => 'foo',
* 'column2' => 1337,
* ),
* array(
* '%s',
* '%d',
* )
* );
* *
* @since 2.5.0 * @since 2.5.0
* *
@ -2587,7 +2492,7 @@ class wpdb {
* Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped). * Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped).
* Sending a null value will cause the column to be set to NULL - the corresponding * Sending a null value will cause the column to be set to NULL - the corresponding
* format is ignored in this case. * format is ignored in this case.
* @param array|string $format Optional. An array of formats to be mapped to each of the value in `$data`. * @param string[]|string $format Optional. An array of formats to be mapped to each of the value in `$data`.
* If string, that format will be used for all of the values in `$data`. * If string, that format will be used for all of the values in `$data`.
* A format is one of '%d', '%f', '%s' (integer, float, string). * A format is one of '%d', '%f', '%s' (integer, float, string).
* If omitted, all values in `$data` will be treated as strings unless otherwise * If omitted, all values in `$data` will be treated as strings unless otherwise
@ -2599,12 +2504,34 @@ class wpdb {
} }
/** /**
* Replaces a row in the table. * Replaces a row in the table or inserts it if it does not exist, based on a PRIMARY KEY or a UNIQUE index.
*
* A REPLACE works exactly like an INSERT, except that if an old row in the table has the same value as a new row
* for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted.
* *
* Examples: * Examples:
* *
* wpdb::replace( 'table', array( 'column' => 'foo', 'field' => 'bar' ) ) * $wpdb->replace(
* wpdb::replace( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( '%s', '%d' ) ) * 'table',
* array(
* 'ID' => 123,
* 'column1' => 'foo',
* 'column2' => 'bar',
* )
* );
* $wpdb->replace(
* 'table',
* array(
* 'ID' => 456,
* 'column1' => 'foo',
* 'column2' => 1337,
* ),
* array(
* '%d',
* '%s',
* '%d',
* )
* );
* *
* @since 3.0.0 * @since 3.0.0
* *
@ -2615,9 +2542,10 @@ class wpdb {
* @param string $table Table name. * @param string $table Table name.
* @param array $data Data to insert (in column => value pairs). * @param array $data Data to insert (in column => value pairs).
* Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped). * Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped).
* A primary key or unique index is required to perform a replace operation.
* Sending a null value will cause the column to be set to NULL - the corresponding * Sending a null value will cause the column to be set to NULL - the corresponding
* format is ignored in this case. * format is ignored in this case.
* @param array|string $format Optional. An array of formats to be mapped to each of the value in `$data`. * @param string[]|string $format Optional. An array of formats to be mapped to each of the value in `$data`.
* If string, that format will be used for all of the values in `$data`. * If string, that format will be used for all of the values in `$data`.
* A format is one of '%d', '%f', '%s' (integer, float, string). * A format is one of '%d', '%f', '%s' (integer, float, string).
* If omitted, all values in `$data` will be treated as strings unless otherwise * If omitted, all values in `$data` will be treated as strings unless otherwise
@ -2644,7 +2572,7 @@ class wpdb {
* Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped). * Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped).
* Sending a null value will cause the column to be set to NULL - the corresponding * Sending a null value will cause the column to be set to NULL - the corresponding
* format is ignored in this case. * format is ignored in this case.
* @param array|string $format Optional. An array of formats to be mapped to each of the value in `$data`. * @param string[]|string $format Optional. An array of formats to be mapped to each of the value in `$data`.
* If string, that format will be used for all of the values in `$data`. * If string, that format will be used for all of the values in `$data`.
* A format is one of '%d', '%f', '%s' (integer, float, string). * A format is one of '%d', '%f', '%s' (integer, float, string).
* If omitted, all values in `$data` will be treated as strings unless otherwise * If omitted, all values in `$data` will be treated as strings unless otherwise
@ -2691,8 +2619,33 @@ class wpdb {
* *
* Examples: * Examples:
* *
* wpdb::update( 'table', array( 'column' => 'foo', 'field' => 'bar' ), array( 'ID' => 1 ) ) * $wpdb->update(
* wpdb::update( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( 'ID' => 1 ), array( '%s', '%d' ), array( '%d' ) ) * 'table',
* array(
* 'column1' => 'foo',
* 'column2' => 'bar',
* ),
* array(
* 'ID' => 1,
* )
* );
* $wpdb->update(
* 'table',
* array(
* 'column1' => 'foo',
* 'column2' => 1337,
* ),
* array(
* 'ID' => 1,
* ),
* array(
* '%s',
* '%d',
* ),
* array(
* '%d',
* )
* );
* *
* @since 2.5.0 * @since 2.5.0
* *
@ -2710,15 +2663,16 @@ class wpdb {
* Both $where columns and $where values should be "raw". * Both $where columns and $where values should be "raw".
* Sending a null value will create an IS NULL comparison - the corresponding * Sending a null value will create an IS NULL comparison - the corresponding
* format will be ignored in this case. * format will be ignored in this case.
* @param array|string $format Optional. An array of formats to be mapped to each of the values in $data. * @param string[]|string $format Optional. An array of formats to be mapped to each of the values in $data.
* If string, that format will be used for all of the values in $data. * If string, that format will be used for all of the values in $data.
* A format is one of '%d', '%f', '%s' (integer, float, string). * A format is one of '%d', '%f', '%s' (integer, float, string).
* If omitted, all values in $data will be treated as strings unless otherwise * If omitted, all values in $data will be treated as strings unless otherwise
* specified in wpdb::$field_types. Default null. * specified in wpdb::$field_types. Default null.
* @param array|string $where_format Optional. An array of formats to be mapped to each of the values in $where. * @param string[]|string $where_format Optional. An array of formats to be mapped to each of the values in $where.
* If string, that format will be used for all of the items in $where. * If string, that format will be used for all of the items in $where.
* A format is one of '%d', '%f', '%s' (integer, float, string). * A format is one of '%d', '%f', '%s' (integer, float, string).
* If omitted, all values in $where will be treated as strings. Default null. * If omitted, all values in $where will be treated as strings unless otherwise
* specified in wpdb::$field_types. Default null.
* @return int|false The number of rows updated, or false on error. * @return int|false The number of rows updated, or false on error.
*/ */
public function update( $table, $data, $where, $format = null, $where_format = null ) { public function update( $table, $data, $where, $format = null, $where_format = null ) {
@ -2771,8 +2725,21 @@ class wpdb {
* *
* Examples: * Examples:
* *
* wpdb::delete( 'table', array( 'ID' => 1 ) ) * $wpdb->delete(
* wpdb::delete( 'table', array( 'ID' => 1 ), array( '%d' ) ) * 'table',
* array(
* 'ID' => 1,
* )
* );
* $wpdb->delete(
* 'table',
* array(
* 'ID' => 1,
* ),
* array(
* '%d',
* )
* );
* *
* @since 3.4.0 * @since 3.4.0
* *
@ -2786,7 +2753,7 @@ class wpdb {
* Both $where columns and $where values should be "raw". * Both $where columns and $where values should be "raw".
* Sending a null value will create an IS NULL comparison - the corresponding * Sending a null value will create an IS NULL comparison - the corresponding
* format will be ignored in this case. * format will be ignored in this case.
* @param array|string $where_format Optional. An array of formats to be mapped to each of the values in $where. * @param string[]|string $where_format Optional. An array of formats to be mapped to each of the values in $where.
* If string, that format will be used for all of the items in $where. * If string, that format will be used for all of the items in $where.
* A format is one of '%d', '%f', '%s' (integer, float, string). * A format is one of '%d', '%f', '%s' (integer, float, string).
* If omitted, all values in $data will be treated as strings unless otherwise * If omitted, all values in $data will be treated as strings unless otherwise
@ -2835,8 +2802,8 @@ class wpdb {
* @since 4.2.0 * @since 4.2.0
* *
* @param string $table Table name. * @param string $table Table name.
* @param array $data Field/value pair. * @param array $data Array of values keyed by their field names.
* @param mixed $format Format for each field. * @param string[]|string $format Formats or format to be mapped to the values in the data.
* @return array|false An array of fields that contain paired value and formats. * @return array|false An array of fields that contain paired value and formats.
* False for invalid values. * False for invalid values.
*/ */
@ -2894,10 +2861,14 @@ class wpdb {
* *
* @since 4.2.0 * @since 4.2.0
* *
* @param array $data Array of fields to values. * @param array $data Array of values keyed by their field names.
* @param mixed $format Formats to be mapped to the values in $data. * @param string[]|string $format Formats or format to be mapped to the values in the data.
* @return array Array, keyed by field names with values being an array * @return array {
* of 'value' and 'format' keys. * Array of values and formats keyed by their field names.
*
* @type mixed $value The value to be formatted.
* @type string $format The format to be mapped to the value.
* }
*/ */
protected function process_field_formats( $data, $format ) { protected function process_field_formats( $data, $format ) {
$formats = (array) $format; $formats = (array) $format;
@ -2929,10 +2900,30 @@ class wpdb {
* *
* @since 4.2.0 * @since 4.2.0
* *
* @param array $data As it comes from the wpdb::process_field_formats() method. * @param array $data {
* Array of values and formats keyed by their field names,
* as it comes from the wpdb::process_field_formats() method.
*
* @type array ...$0 {
* Value and format for this field.
*
* @type mixed $value The value to be formatted.
* @type string $format The format to be mapped to the value.
* }
* }
* @param string $table Table name. * @param string $table Table name.
* @return array|false The same array as $data with additional 'charset' keys. * @return array|false {
* False on failure. * The same array of data with additional 'charset' keys, or false if
* the charset for the table cannot be found.
*
* @type array ...$0 {
* Value, format, and charset for this field.
*
* @type mixed $value The value to be formatted.
* @type string $format The format to be mapped to the value.
* @type string|false $charset The charset to be used for the value.
* }
* }
*/ */
protected function process_field_charsets( $data, $table ) { protected function process_field_charsets( $data, $table ) {
foreach ( $data as $field => $value ) { foreach ( $data as $field => $value ) {
@ -2960,10 +2951,38 @@ class wpdb {
* *
* @since 4.2.1 * @since 4.2.1
* *
* @param array $data As it comes from the wpdb::process_field_charsets() method. * @param array $data {
* Array of values, formats, and charsets keyed by their field names,
* as it comes from the wpdb::process_field_charsets() method.
*
* @type array ...$0 {
* Value, format, and charset for this field.
*
* @type mixed $value The value to be formatted.
* @type string $format The format to be mapped to the value.
* @type string|false $charset The charset to be used for the value.
* }
* }
* @param string $table Table name. * @param string $table Table name.
* @return array|false The same array as $data with additional 'length' keys, or false if * @return array|false {
* any of the values were too long for their corresponding field. * The same array of data with additional 'length' keys, or false if
* information for the table cannot be found.
*
* @type array ...$0 {
* Value, format, charset, and length for this field.
*
* @type mixed $value The value to be formatted.
* @type string $format The format to be mapped to the value.
* @type string|false $charset The charset to be used for the value.
* @type array|false $length {
* Information about the maximum length of the value.
* False if the column has no length.
*
* @type string $type One of 'byte' or 'char'.
* @type int $length The column length.
* }
* }
* }
*/ */
protected function process_field_lengths( $data, $table ) { protected function process_field_lengths( $data, $table ) {
foreach ( $data as $field => $value ) { foreach ( $data as $field => $value ) {
@ -2987,7 +3006,7 @@ class wpdb {
} }
/** /**
* Retrieves one variable from the database. * Retrieves one value from the database.
* *
* Executes a SQL query and returns the value from the SQL result. * Executes a SQL query and returns the value from the SQL result.
* If the SQL result contains more than one column and/or more than one row, * If the SQL result contains more than one column and/or more than one row,
@ -3295,7 +3314,7 @@ class wpdb {
* *
* @since 4.2.0 * @since 4.2.0
* *
* @param string|null $charset The character set to use. Default null. * @param string|null|false|WP_Error $charset The character set to use. Default null.
* @param string $table The name of the table being checked. * @param string $table The name of the table being checked.
* @param string $column The name of the column being checked. * @param string $column The name of the column being checked.
*/ */
@ -3349,8 +3368,8 @@ class wpdb {
* Array of column length information, false if the column has no length (for * Array of column length information, false if the column has no length (for
* example, numeric column), WP_Error object if there was an error. * example, numeric column), WP_Error object if there was an error.
* *
* @type int $length The column length.
* @type string $type One of 'byte' or 'char'. * @type string $type One of 'byte' or 'char'.
* @type int $length The column length.
* } * }
*/ */
public function get_col_length( $table, $column ) { public function get_col_length( $table, $column ) {
@ -3525,7 +3544,7 @@ class wpdb {
* *
* @since 4.2.0 * @since 4.2.0
* *
* @param array $data Array of value arrays. Each value array has the keys 'value' and 'charset'. * @param array $data Array of value arrays. Each value array has the keys 'value', 'charset', and 'length'.
* An optional 'ascii' key can be set to false to avoid redundant ASCII checks. * An optional 'ascii' key can be set to false to avoid redundant ASCII checks.
* @return array|WP_Error The $data parameter, with invalid characters removed from each value. * @return array|WP_Error The $data parameter, with invalid characters removed from each value.
* This works as a passthrough: any additional keys such as 'field' are * This works as a passthrough: any additional keys such as 'field' are
@ -3636,11 +3655,7 @@ class wpdb {
if ( $this->charset ) { if ( $this->charset ) {
$connection_charset = $this->charset; $connection_charset = $this->charset;
} else { } else {
if ( $this->use_mysqli ) {
$connection_charset = mysqli_character_set_name( $this->dbh ); $connection_charset = mysqli_character_set_name( $this->dbh );
} else {
$connection_charset = mysql_client_encoding();
}
} }
if ( is_array( $value['length'] ) ) { if ( is_array( $value['length'] ) ) {
@ -3850,17 +3865,11 @@ class wpdb {
return; return;
} }
if ( $this->use_mysqli ) {
$num_fields = mysqli_num_fields( $this->result ); $num_fields = mysqli_num_fields( $this->result );
for ( $i = 0; $i < $num_fields; $i++ ) { for ( $i = 0; $i < $num_fields; $i++ ) {
$this->col_info[ $i ] = mysqli_fetch_field( $this->result ); $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 );
}
}
} }
/** /**
@ -3884,7 +3893,7 @@ class wpdb {
$new_array = array(); $new_array = array();
foreach ( (array) $this->col_info as $col ) { foreach ( (array) $this->col_info as $col ) {
$new_array[ $i ] = $col->{$info_type}; $new_array[ $i ] = $col->{$info_type};
$i++; ++$i;
} }
return $new_array; return $new_array;
} else { } else {
@ -3932,19 +3941,11 @@ class wpdb {
if ( $this->show_errors ) { if ( $this->show_errors ) {
$error = ''; $error = '';
if ( $this->use_mysqli ) {
if ( $this->dbh instanceof mysqli ) { if ( $this->dbh instanceof mysqli ) {
$error = mysqli_error( $this->dbh ); $error = mysqli_error( $this->dbh );
} elseif ( mysqli_connect_errno() ) { } elseif ( mysqli_connect_errno() ) {
$error = mysqli_connect_error(); $error = mysqli_connect_error();
} }
} else {
if ( is_resource( $this->dbh ) ) {
$error = mysql_error( $this->dbh );
} else {
$error = mysql_error();
}
}
if ( $error ) { if ( $error ) {
$message = '<p><code>' . $error . "</code></p>\n" . $message; $message = '<p><code>' . $error . "</code></p>\n" . $message;
@ -3975,11 +3976,7 @@ class wpdb {
return false; return false;
} }
if ( $this->use_mysqli ) {
$closed = mysqli_close( $this->dbh ); $closed = mysqli_close( $this->dbh );
} else {
$closed = mysql_close( $this->dbh );
}
if ( $closed ) { if ( $closed ) {
$this->dbh = null; $this->dbh = null;
@ -4098,11 +4095,8 @@ class wpdb {
if ( version_compare( $db_version, '5.5.3', '<' ) ) { if ( version_compare( $db_version, '5.5.3', '<' ) ) {
return false; return false;
} }
if ( $this->use_mysqli ) {
$client_version = mysqli_get_client_info(); $client_version = mysqli_get_client_info();
} else {
$client_version = mysql_get_client_info();
}
/* /*
* libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server. * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
@ -4154,19 +4148,13 @@ class wpdb {
} }
/** /**
* Retrieves full database server information. * Returns the version of the MySQL server.
* *
* @since 5.5.0 * @since 5.5.0
* *
* @return string|false Server info on success, false on failure. * @return string Server version as a string.
*/ */
public function db_server_info() { public function db_server_info() {
if ( $this->use_mysqli ) { return mysqli_get_server_info( $this->dbh );
$server_info = mysqli_get_server_info( $this->dbh );
} else {
$server_info = mysql_get_server_info( $this->dbh );
}
return $server_info;
} }
} }

View File

@ -1517,7 +1517,7 @@ function wp_get_pomo_file_data( $po_file ) {
* *
* @type string $id ID attribute of the select element. Default 'locale'. * @type string $id ID attribute of the select element. Default 'locale'.
* @type string $name Name attribute of the select element. Default 'locale'. * @type string $name Name attribute of the select element. Default 'locale'.
* @type array $languages List of installed languages, contain only the locales. * @type string[] $languages List of installed languages, contain only the locales.
* Default empty array. * Default empty array.
* @type array $translations List of available translations. Default result of * @type array $translations List of available translations. Default result of
* wp_get_available_translations(). * wp_get_available_translations().

View File

@ -16,14 +16,14 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.3.2'; $wp_version = '6.4.1';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
* *
* @global int $wp_db_version * @global int $wp_db_version
*/ */
$wp_db_version = 55853; $wp_db_version = 56657;
/** /**
* Holds the TinyMCE version. * Holds the TinyMCE version.