From 07f3c3546723aef0e3e6965dd828e4a06015b69d Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Wed, 22 Sep 2021 21:01:00 +0000 Subject: [PATCH] General: Fix code quality issues which were identified by static analysis. This fixes minor issues that could cause PHP notices under the right conditions, and fixes some general incorrectness. Props jrf, hellofromTonya for review See #52217 Built from https://develop.svn.wordpress.org/trunk@51850 git-svn-id: http://core.svn.wordpress.org/trunk@51449 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit.php | 2 +- wp-admin/includes/class-wp-list-table.php | 6 +++++- wp-includes/class-wp-http-curl.php | 2 +- wp-includes/class-wp-http-streams.php | 2 +- wp-includes/post.php | 4 ++++ wp-includes/version.php | 2 +- wp-includes/widgets.php | 7 ++++--- wp-includes/widgets/class-wp-widget-tag-cloud.php | 2 ++ wp-mail.php | 3 +++ 9 files changed, 22 insertions(+), 8 deletions(-) diff --git a/wp-admin/edit.php b/wp-admin/edit.php index 2b917b994d..bd537bd49e 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -154,7 +154,7 @@ if ( $doaction ) { } $sendback = add_query_arg( 'untrashed', $untrashed, $sendback ); - remove_filter( 'wp_untrash_post_status', 'wp_untrash_post_set_previous_status', 10, 3 ); + remove_filter( 'wp_untrash_post_status', 'wp_untrash_post_set_previous_status', 10 ); break; case 'delete': diff --git a/wp-admin/includes/class-wp-list-table.php b/wp-admin/includes/class-wp-list-table.php index 535f5d5f81..2cae7f695a 100644 --- a/wp-admin/includes/class-wp-list-table.php +++ b/wp-admin/includes/class-wp-list-table.php @@ -207,12 +207,14 @@ class WP_List_Table { * @since 4.0.0 * * @param string $name Property to check if set. - * @return bool Whether the property is set. + * @return bool Whether the property is a back-compat property and it is set. */ public function __isset( $name ) { if ( in_array( $name, $this->compat_fields, true ) ) { return isset( $this->$name ); } + + return false; } /** @@ -313,6 +315,8 @@ class WP_List_Table { if ( isset( $this->_pagination_args[ $key ] ) ) { return $this->_pagination_args[ $key ]; } + + return 0; } /** diff --git a/wp-includes/class-wp-http-curl.php b/wp-includes/class-wp-http-curl.php index 9b6e0eb10b..64ff7efb83 100644 --- a/wp-includes/class-wp-http-curl.php +++ b/wp-includes/class-wp-http-curl.php @@ -307,7 +307,7 @@ class WP_Http_Curl { ); // Handle redirects. - $redirect_response = WP_HTTP::handle_redirects( $url, $parsed_args, $response ); + $redirect_response = WP_Http::handle_redirects( $url, $parsed_args, $response ); if ( false !== $redirect_response ) { return $redirect_response; } diff --git a/wp-includes/class-wp-http-streams.php b/wp-includes/class-wp-http-streams.php index 95ff2a1a20..d6cfc53359 100644 --- a/wp-includes/class-wp-http-streams.php +++ b/wp-includes/class-wp-http-streams.php @@ -470,6 +470,6 @@ class WP_Http_Streams { * @since 2.7.0 * @deprecated 3.7.0 Please use WP_HTTP::request() directly */ -class WP_HTTP_Fsockopen extends WP_HTTP_Streams { +class WP_HTTP_Fsockopen extends WP_Http_Streams { // For backward compatibility for users who are using the class directly. } diff --git a/wp-includes/post.php b/wp-includes/post.php index 1adc89908a..2487e5b4c2 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -5506,6 +5506,8 @@ function get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) { if ( $foundid ) { return get_post( $foundid, $output ); } + + return null; } /** @@ -5563,6 +5565,8 @@ function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) if ( $page ) { return get_post( $page, $output ); } + + return null; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 2dc15dcd63..3b63098d48 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '5.9-alpha-51849'; +$wp_version = '5.9-alpha-51850'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/widgets.php b/wp-includes/widgets.php index 10f5017957..de15317d1b 100644 --- a/wp-includes/widgets.php +++ b/wp-includes/widgets.php @@ -1739,11 +1739,12 @@ function wp_widget_rss_process( $widget_rss, $check_feed = true ) { $show_summary = isset( $widget_rss['show_summary'] ) ? (int) $widget_rss['show_summary'] : 0; $show_author = isset( $widget_rss['show_author'] ) ? (int) $widget_rss['show_author'] : 0; $show_date = isset( $widget_rss['show_date'] ) ? (int) $widget_rss['show_date'] : 0; + $error = false; + $link = ''; if ( $check_feed ) { - $rss = fetch_feed( $url ); - $error = false; - $link = ''; + $rss = fetch_feed( $url ); + if ( is_wp_error( $rss ) ) { $error = $rss->get_error_message(); } else { diff --git a/wp-includes/widgets/class-wp-widget-tag-cloud.php b/wp-includes/widgets/class-wp-widget-tag-cloud.php index fb17e69a16..52b06d9b60 100644 --- a/wp-includes/widgets/class-wp-widget-tag-cloud.php +++ b/wp-includes/widgets/class-wp-widget-tag-cloud.php @@ -53,6 +53,8 @@ class WP_Widget_Tag_Cloud extends WP_Widget { } } + $default_title = $title; + $show_count = ! empty( $instance['count'] ); $tag_cloud = wp_tag_cloud( diff --git a/wp-mail.php b/wp-mail.php index 1d5fbedf03..c3f921ad69 100644 --- a/wp-mail.php +++ b/wp-mail.php @@ -77,6 +77,9 @@ for ( $i = 1; $i <= $count; $i++ ) { $content_transfer_encoding = ''; $post_author = 1; $author_found = false; + $post_date = null; + $post_date_gmt = null; + foreach ( $message as $line ) { // Body signal. if ( strlen( $line ) < 3 ) {