From 0ec87e45845d45347674e01b7e421375e379994a Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 9 Mar 2015 02:11:28 +0000 Subject: [PATCH] There are a few functions that have the ability to return `false` instead of a string, so the return value should be checked before being passed to functions that expect string. These are trivial, but they clear out some Scrutinizer issues. See #30799. Built from https://develop.svn.wordpress.org/trunk@31681 git-svn-id: http://core.svn.wordpress.org/trunk@31662 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 4 +++- wp-admin/edit-form-comment.php | 3 ++- wp-admin/includes/class-wp-comments-list-table.php | 3 +++ wp-admin/includes/post.php | 8 +++++--- wp-admin/network/themes.php | 5 ++++- wp-admin/plugins.php | 5 ++++- wp-admin/upgrade.php | 6 ++++-- wp-includes/class-http.php | 4 +++- wp-includes/theme.php | 7 +++++-- wp-includes/version.php | 2 +- 10 files changed, 34 insertions(+), 13 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index d6a8480dcb..92f56b7038 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -426,6 +426,8 @@ if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create * @param WP_Post $post Post object. */ do_action( 'post_edit_form_tag', $post ); + +$referer = wp_get_referer(); ?>> @@ -434,7 +436,7 @@ do_action( 'post_edit_form_tag', $post ); - + - + diff --git a/wp-admin/includes/class-wp-comments-list-table.php b/wp-admin/includes/class-wp-comments-list-table.php index f648063e11..8a04b7f6a2 100644 --- a/wp-admin/includes/class-wp-comments-list-table.php +++ b/wp-admin/includes/class-wp-comments-list-table.php @@ -361,6 +361,9 @@ class WP_Comments_List_Table extends WP_List_Table { $comment = $a_comment; $the_comment_class = wp_get_comment_status( $comment->comment_ID ); + if ( ! $the_comment_class ) { + $the_comment_class = ''; + } $the_comment_class = join( ' ', get_comment_class( $the_comment_class, $comment->comment_ID, $comment->comment_post_ID ) ); $post = get_post( $comment->comment_post_ID ); diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 1e6d9fa3bc..545c57f56e 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -1220,9 +1220,11 @@ function get_sample_permalink($id, $title = null, $name = null) { // Handle page hierarchy if ( $ptype->hierarchical ) { $uri = get_page_uri($post); - $uri = untrailingslashit($uri); - $uri = strrev( stristr( strrev( $uri ), '/' ) ); - $uri = untrailingslashit($uri); + if ( $uri ) { + $uri = untrailingslashit($uri); + $uri = strrev( stristr( strrev( $uri ), '/' ) ); + $uri = untrailingslashit($uri); + } /** This filter is documented in wp-admin/edit-tag-form.php */ $uri = apply_filters( 'editable_slug', $uri ); diff --git a/wp-admin/network/themes.php b/wp-admin/network/themes.php index 3d4e02dce0..18966d3a20 100644 --- a/wp-admin/network/themes.php +++ b/wp-admin/network/themes.php @@ -174,7 +174,10 @@ if ( $action ) { -
+ +
diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 629fdbff53..265c1ea7c3 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -321,7 +321,10 @@ if ( $action ) { -
+ +
diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php index ece3eb056f..4db7f088b4 100644 --- a/wp-admin/upgrade.php +++ b/wp-admin/upgrade.php @@ -81,8 +81,10 @@ else switch ( $step ) : case 0: $goback = wp_get_referer(); - $goback = esc_url_raw( $goback ); - $goback = urlencode( $goback ); + if ( $goback ) { + $goback = esc_url_raw( $goback ); + $goback = urlencode( $goback ); + } ?>

diff --git a/wp-includes/class-http.php b/wp-includes/class-http.php index 2b27658f89..8a655f006b 100644 --- a/wp-includes/class-http.php +++ b/wp-includes/class-http.php @@ -182,7 +182,9 @@ class WP_Http { if ( function_exists( 'wp_kses_bad_protocol' ) ) { if ( $r['reject_unsafe_urls'] ) $url = wp_http_validate_url( $url ); - $url = wp_kses_bad_protocol( $url, array( 'http', 'https', 'ssl' ) ); + if ( $url ) { + $url = wp_kses_bad_protocol( $url, array( 'http', 'https', 'ssl' ) ); + } } $arrURL = @parse_url( $url ); diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 3f5b5e7455..d2eb765edf 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1050,7 +1050,7 @@ function has_header_image() { * * @since 2.1.0 * - * @return string + * @return string|false */ function get_header_image() { $url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) ); @@ -1153,7 +1153,10 @@ function is_random_header_image( $type = 'any' ) { * @since 2.1.0 */ function header_image() { - echo esc_url( get_header_image() ); + $image = get_header_image(); + if ( $image ) { + echo esc_url( $image ); + } } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 6f274d50b2..1d9612900a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31680'; +$wp_version = '4.2-alpha-31681'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.