General: Continuing to work towards a passing PHP Compatibility scan.
This is a final pass to fix PHP compatibiilty issues in the codebase with code changes or adding `phpcs:ignore` comments. With this change, all PHP compatibility warnings and errors without specific tickets have been addressed (see #49810 and #41750). Props desrosj, johnbillion, jrf. See #49922. git-svn-id: https://develop.svn.wordpress.org/trunk@47902 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2da8918f1a
commit
dfccba8d55
@ -74,7 +74,7 @@
|
|||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Whitelist the WP DB Class for use of `mysql_` extension in PHP < 7.0. -->
|
<!-- Whitelist the WP DB Class for use of `mysql_` extension in PHP < 7.0. -->
|
||||||
<rule ref="PHPCompatibility.Extensions.RemovedExtensions">
|
<rule ref="PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved">
|
||||||
<exclude-pattern>/src/wp-includes/wp-db\.php</exclude-pattern>
|
<exclude-pattern>/src/wp-includes/wp-db\.php</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
@ -899,7 +899,7 @@ class ftp_base {
|
|||||||
$mod_sockets = extension_loaded( 'sockets' );
|
$mod_sockets = extension_loaded( 'sockets' );
|
||||||
if ( ! $mod_sockets && function_exists( 'dl' ) && is_callable( 'dl' ) ) {
|
if ( ! $mod_sockets && function_exists( 'dl' ) && is_callable( 'dl' ) ) {
|
||||||
$prefix = ( PHP_SHLIB_SUFFIX == 'dll' ) ? 'php_' : '';
|
$prefix = ( PHP_SHLIB_SUFFIX == 'dll' ) ? 'php_' : '';
|
||||||
@dl( $prefix . 'sockets.' . PHP_SHLIB_SUFFIX );
|
@dl( $prefix . 'sockets.' . PHP_SHLIB_SUFFIX ); // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.dlDeprecated
|
||||||
$mod_sockets = extension_loaded( 'sockets' );
|
$mod_sockets = extension_loaded( 'sockets' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ class getid3_quicktime extends getid3_handler
|
|||||||
foreach ($info['quicktime']['comments']['location.ISO6709'] as $ISO6709string) {
|
foreach ($info['quicktime']['comments']['location.ISO6709'] as $ISO6709string) {
|
||||||
$ISO6709parsed = array('latitude'=>false, 'longitude'=>false, 'altitude'=>false);
|
$ISO6709parsed = array('latitude'=>false, 'longitude'=>false, 'altitude'=>false);
|
||||||
if (preg_match('#^([\\+\\-])([0-9]{2}|[0-9]{4}|[0-9]{6})(\\.[0-9]+)?([\\+\\-])([0-9]{3}|[0-9]{5}|[0-9]{7})(\\.[0-9]+)?(([\\+\\-])([0-9]{3}|[0-9]{5}|[0-9]{7})(\\.[0-9]+)?)?/$#', $ISO6709string, $matches)) {
|
if (preg_match('#^([\\+\\-])([0-9]{2}|[0-9]{4}|[0-9]{6})(\\.[0-9]+)?([\\+\\-])([0-9]{3}|[0-9]{5}|[0-9]{7})(\\.[0-9]+)?(([\\+\\-])([0-9]{3}|[0-9]{5}|[0-9]{7})(\\.[0-9]+)?)?/$#', $ISO6709string, $matches)) {
|
||||||
@list($dummy, $lat_sign, $lat_deg, $lat_deg_dec, $lon_sign, $lon_deg, $lon_deg_dec, $dummy, $alt_sign, $alt_deg, $alt_deg_dec) = $matches;
|
@list($dummy, $lat_sign, $lat_deg, $lat_deg_dec, $lon_sign, $lon_deg, $lon_deg_dec, $dummy, $alt_sign, $alt_deg, $alt_deg_dec) = $matches; // phpcs:ignore PHPCompatibility.Lists.AssignmentOrder.Affected
|
||||||
|
|
||||||
if (strlen($lat_deg) == 2) { // [+-]DD.D
|
if (strlen($lat_deg) == 2) { // [+-]DD.D
|
||||||
$ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * floatval(ltrim($lat_deg, '0').$lat_deg_dec);
|
$ISO6709parsed['latitude'] = (($lat_sign == '-') ? -1 : 1) * floatval(ltrim($lat_deg, '0').$lat_deg_dec);
|
||||||
|
@ -290,8 +290,8 @@ function map_meta_cap( $cap, $user_id, ...$args ) {
|
|||||||
case 'edit_user_meta':
|
case 'edit_user_meta':
|
||||||
case 'delete_user_meta':
|
case 'delete_user_meta':
|
||||||
case 'add_user_meta':
|
case 'add_user_meta':
|
||||||
list( $_, $object_type, $_ ) = explode( '_', $cap );
|
$object_type = explode( '_', $cap )[1];
|
||||||
$object_id = (int) $args[0];
|
$object_id = (int) $args[0];
|
||||||
|
|
||||||
$object_subtype = get_object_subtype( $object_type, $object_id );
|
$object_subtype = get_object_subtype( $object_type, $object_id );
|
||||||
|
|
||||||
|
@ -187,7 +187,8 @@ class Requests {
|
|||||||
|
|
||||||
// Don't search for a transport if it's already been done for these $capabilities
|
// Don't search for a transport if it's already been done for these $capabilities
|
||||||
if (isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) {
|
if (isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) {
|
||||||
return new self::$transport[$cap_string]();
|
$class = self::$transport[$cap_string];
|
||||||
|
return new $class();
|
||||||
}
|
}
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
@ -214,7 +215,8 @@ class Requests {
|
|||||||
throw new Requests_Exception('No working transports found', 'notransport', self::$transports);
|
throw new Requests_Exception('No working transports found', 'notransport', self::$transports);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new self::$transport[$cap_string]();
|
$class = self::$transport[$cap_string];
|
||||||
|
return new $class();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
|
@ -3165,7 +3165,7 @@ class SimplePie
|
|||||||
}
|
}
|
||||||
|
|
||||||
$class = get_class($this);
|
$class = get_class($this);
|
||||||
$trace = debug_backtrace();
|
$trace = debug_backtrace(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
|
||||||
$file = $trace[0]['file'];
|
$file = $trace[0]['file'];
|
||||||
$line = $trace[0]['line'];
|
$line = $trace[0]['line'];
|
||||||
trigger_error("Call to undefined method $class::$method() in $file on line $line", E_USER_ERROR);
|
trigger_error("Call to undefined method $class::$method() in $file on line $line", E_USER_ERROR);
|
||||||
|
@ -402,7 +402,7 @@ function wp_clear_scheduled_hook( $hook, $args = array() ) {
|
|||||||
// Previously, this function took the arguments as discrete vars rather than an array like the rest of the API.
|
// Previously, this function took the arguments as discrete vars rather than an array like the rest of the API.
|
||||||
if ( ! is_array( $args ) ) {
|
if ( ! is_array( $args ) ) {
|
||||||
_deprecated_argument( __FUNCTION__, '3.0.0', __( 'This argument has changed to an array to match the behavior of the other cron functions.' ) );
|
_deprecated_argument( __FUNCTION__, '3.0.0', __( 'This argument has changed to an array to match the behavior of the other cron functions.' ) );
|
||||||
$args = array_slice( func_get_args(), 1 );
|
$args = array_slice( func_get_args(), 1 ); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6627,7 +6627,7 @@ function mbstring_binary_safe_encoding( $reset = false ) {
|
|||||||
static $overloaded = null;
|
static $overloaded = null;
|
||||||
|
|
||||||
if ( is_null( $overloaded ) ) {
|
if ( is_null( $overloaded ) ) {
|
||||||
$overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 );
|
$overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 ); // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( false === $overloaded ) {
|
if ( false === $overloaded ) {
|
||||||
|
@ -231,7 +231,7 @@ function apply_filters_ref_array( $tag, $args ) {
|
|||||||
// Do 'all' actions first.
|
// Do 'all' actions first.
|
||||||
if ( isset( $wp_filter['all'] ) ) {
|
if ( isset( $wp_filter['all'] ) ) {
|
||||||
$wp_current_filter[] = $tag;
|
$wp_current_filter[] = $tag;
|
||||||
$all_args = func_get_args();
|
$all_args = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
|
||||||
_wp_call_all_hook( $all_args );
|
_wp_call_all_hook( $all_args );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ function do_action( $tag, ...$arg ) {
|
|||||||
// Do 'all' actions first.
|
// Do 'all' actions first.
|
||||||
if ( isset( $wp_filter['all'] ) ) {
|
if ( isset( $wp_filter['all'] ) ) {
|
||||||
$wp_current_filter[] = $tag;
|
$wp_current_filter[] = $tag;
|
||||||
$all_args = func_get_args();
|
$all_args = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
|
||||||
_wp_call_all_hook( $all_args );
|
_wp_call_all_hook( $all_args );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,7 +526,7 @@ function do_action_ref_array( $tag, $args ) {
|
|||||||
// Do 'all' actions first.
|
// Do 'all' actions first.
|
||||||
if ( isset( $wp_filter['all'] ) ) {
|
if ( isset( $wp_filter['all'] ) ) {
|
||||||
$wp_current_filter[] = $tag;
|
$wp_current_filter[] = $tag;
|
||||||
$all_args = func_get_args();
|
$all_args = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
|
||||||
_wp_call_all_hook( $all_args );
|
_wp_call_all_hook( $all_args );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ if ( ! class_exists( 'POMO_Reader', false ) ) :
|
|||||||
* PHP5 constructor.
|
* PHP5 constructor.
|
||||||
*/
|
*/
|
||||||
function __construct() {
|
function __construct() {
|
||||||
$this->is_overloaded = ( ( ini_get( 'mbstring.func_overload' ) & 2 ) != 0 ) && function_exists( 'mb_substr' );
|
$this->is_overloaded = ( ( ini_get( 'mbstring.func_overload' ) & 2 ) != 0 ) && function_exists( 'mb_substr' ); // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated
|
||||||
$this->_pos = 0;
|
$this->_pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,10 +385,6 @@ class MagpieRSS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function error( $errormsg, $lvl = E_USER_WARNING ) {
|
function error( $errormsg, $lvl = E_USER_WARNING ) {
|
||||||
// append PHP's error message if track_errors enabled
|
|
||||||
if ( isset($php_errormsg) ) {
|
|
||||||
$errormsg .= " ($php_errormsg)";
|
|
||||||
}
|
|
||||||
if ( MAGPIE_DEBUG ) {
|
if ( MAGPIE_DEBUG ) {
|
||||||
trigger_error( $errormsg, $lvl);
|
trigger_error( $errormsg, $lvl);
|
||||||
} else {
|
} else {
|
||||||
@ -821,10 +817,6 @@ class RSSCache {
|
|||||||
Purpose: register error
|
Purpose: register error
|
||||||
\*=======================================================================*/
|
\*=======================================================================*/
|
||||||
function error ($errormsg, $lvl=E_USER_WARNING) {
|
function error ($errormsg, $lvl=E_USER_WARNING) {
|
||||||
// append PHP's error message if track_errors enabled
|
|
||||||
if ( isset($php_errormsg) ) {
|
|
||||||
$errormsg .= " ($php_errormsg)";
|
|
||||||
}
|
|
||||||
$this->ERROR = $errormsg;
|
$this->ERROR = $errormsg;
|
||||||
if ( MAGPIE_DEBUG ) {
|
if ( MAGPIE_DEBUG ) {
|
||||||
trigger_error( $errormsg, $lvl);
|
trigger_error( $errormsg, $lvl);
|
||||||
|
Loading…
Reference in New Issue
Block a user