From 9d4d3f8fba13be09636bb11197dcc1fffa71e782 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Tue, 9 Nov 2021 22:59:58 +0000 Subject: [PATCH] HTTP API: Ensure value returned from `'http_allowed_safe_ports'` is an array to avoid PHP 8+ TypeError fatal error. Adds an `is_array()` check before the `in_array()`. Why? `in_array()` requires a array for the haystack. Any other data type will cause a fatal error on PHP 8.0 or higher: {{{ Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array }}} As this is a new filter, this type check properly guards to avoid the fatal error. Follow-up to [52084]. See #54331. Built from https://develop.svn.wordpress.org/trunk@52085 git-svn-id: http://core.svn.wordpress.org/trunk@51677 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/http.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/http.php b/wp-includes/http.php index 8dfa62cd20..d76298368f 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -593,7 +593,7 @@ function wp_http_validate_url( $url ) { * @param string $url Requested URL. */ $allowed_ports = apply_filters( 'http_allowed_safe_ports', array( 80, 443, 8080 ), $host, $url ); - if ( in_array( $port, $allowed_ports, true ) ) { + if ( is_array( $allowed_ports ) && in_array( $port, $allowed_ports, true ) ) { return $url; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 884eae9307..59c7c1c870 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-52084'; +$wp_version = '5.9-alpha-52085'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.