From f888767c7322340d9feb0919ac97a64faca2b378 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 12 Jun 2015 17:48:26 +0000 Subject: [PATCH] `$status` shouldn't be loosely compared to `true` in `wp_xmlrpc_server::wp_deleteComment()`. `$initial` shouldn't be loosely compared to `true` in `get_calendar()`. `current_user_can()` shouldn't be loosely compared to `false` in `kses_init()` `$get_all` shouldn't be loosely compared to `true` in `get_blog_details()`. `is_array()` and `in_array()` shouldn't be loosely compared in `wpmu_validate_user_signup()`. `$result` should by strictly compared in `check_ajax_referer()`. `wp_verify_nonce()` should by strictly compared in `_show_post_preview()`. `is_user_logged_in()` should not be loosly compared against `false` in `wp-signup.php`. See #32444. Built from https://develop.svn.wordpress.org/trunk@32733 git-svn-id: http://core.svn.wordpress.org/trunk@32704 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-xmlrpc-server.php | 2 +- wp-includes/general-template.php | 2 +- wp-includes/kses.php | 3 ++- wp-includes/ms-deprecated.php | 4 ++-- wp-includes/ms-functions.php | 15 ++++++++------- wp-includes/pluggable.php | 2 +- wp-includes/revision.php | 2 +- wp-includes/version.php | 2 +- wp-signup.php | 6 +++--- 9 files changed, 20 insertions(+), 18 deletions(-) diff --git a/wp-includes/class-wp-xmlrpc-server.php b/wp-includes/class-wp-xmlrpc-server.php index 53a04162be..ca8d2c1287 100644 --- a/wp-includes/class-wp-xmlrpc-server.php +++ b/wp-includes/class-wp-xmlrpc-server.php @@ -3254,7 +3254,7 @@ class wp_xmlrpc_server extends IXR_Server { $status = wp_delete_comment( $comment_ID ); - if ( true == $status ) { + if ( $status ) { /** * Fires after a comment has been successfully deleted via XML-RPC. * diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index dbf63ef1dc..1945c6738f 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -1645,7 +1645,7 @@ function get_calendar($initial = true, $echo = true) { } foreach ( $myweek as $wd ) { - $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); + $day_name = $initial ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd); $wd = esc_attr($wd); $calendar_output .= "\n\t\t$day_name"; } diff --git a/wp-includes/kses.php b/wp-includes/kses.php index df8bed7028..637fac4627 100644 --- a/wp-includes/kses.php +++ b/wp-includes/kses.php @@ -1461,8 +1461,9 @@ function kses_remove_filters() { function kses_init() { kses_remove_filters(); - if (current_user_can('unfiltered_html') == false) + if ( ! current_user_can( 'unfiltered_html' ) ) { kses_init_filters(); + } } /** diff --git a/wp-includes/ms-deprecated.php b/wp-includes/ms-deprecated.php index beae326fe1..5b6702090b 100644 --- a/wp-includes/ms-deprecated.php +++ b/wp-includes/ms-deprecated.php @@ -210,7 +210,7 @@ function get_most_active_blogs( $num = 10, $display = true ) { $most_active = $t; } - if ( $display == true ) { + if ( $display ) { if ( is_array( $most_active ) ) { reset( $most_active ); foreach ( (array) $most_active as $key => $details ) { @@ -253,7 +253,7 @@ function wpmu_admin_do_redirect( $url = '' ) { wp_redirect( $ref ); exit(); } - if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) { + if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) { wp_redirect( $_SERVER['HTTP_REFERER'] ); exit(); } diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index a29cecd011..89f9ff1b14 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -481,11 +481,11 @@ function wpmu_validate_user_signup($user_name, $user_email) { $errors->add('user_name', __( 'Please enter a username.' ) ); $illegal_names = get_site_option( 'illegal_names' ); - if ( is_array( $illegal_names ) == false ) { + if ( ! is_array( $illegal_names ) ) { $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ); add_site_option( 'illegal_names', $illegal_names ); } - if ( in_array( $user_name, $illegal_names ) == true ) + if ( in_array( $user_name, $illegal_names ) ) $errors->add('user_name', __( 'That username is not allowed.' ) ); if ( is_email_address_unsafe( $user_email ) ) @@ -505,10 +505,11 @@ function wpmu_validate_user_signup($user_name, $user_email) { $errors->add('user_email', __( 'Please enter a valid email address.' ) ); $limited_email_domains = get_site_option( 'limited_email_domains' ); - if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) { + if ( is_array( $limited_email_domains ) && ! empty( $limited_email_domains ) ) { $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) ); - if ( in_array( $emaildomain, $limited_email_domains ) == false ) + if ( ! in_array( $emaildomain, $limited_email_domains ) ) { $errors->add('user_email', __('Sorry, that email address is not allowed!')); + } } // Check if the username has been used already. @@ -627,7 +628,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) $errors->add('blogname', __( 'Only lowercase letters (a-z) and numbers are allowed.' ) ); - if ( in_array( $blogname, $illegal_names ) == true ) + if ( in_array( $blogname, $illegal_names ) ) $errors->add('blogname', __( 'That name is not allowed.' ) ); if ( strlen( $blogname ) < 4 && !is_super_admin() ) @@ -673,7 +674,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { $errors->add( 'blogname', __( 'Sorry, that site already exists!' ) ); if ( username_exists( $blogname ) ) { - if ( is_object( $user ) == false || ( is_object($user) && ( $user->user_login != $blogname ) ) ) + if ( ! is_object( $user ) || ( is_object($user) && ( $user->user_login != $blogname ) ) ) $errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) ); } @@ -1689,7 +1690,7 @@ function get_dirsize( $directory ) { if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) ) return $dirsize[ $directory ][ 'size' ]; - if ( false == is_array( $dirsize ) ) + if ( ! is_array( $dirsize ) ) $dirsize = array(); $dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory ); diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 7870e2fd48..fcf198bd9f 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -1137,7 +1137,7 @@ function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) { $result = wp_verify_nonce( $nonce, $action ); - if ( $die && false == $result ) { + if ( $die && false === $result ) { if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) wp_die( -1 ); else diff --git a/wp-includes/revision.php b/wp-includes/revision.php index ace578e0c3..0ed12e1f9c 100644 --- a/wp-includes/revision.php +++ b/wp-includes/revision.php @@ -522,7 +522,7 @@ function _show_post_preview() { if ( isset($_GET['preview_id']) && isset($_GET['preview_nonce']) ) { $id = (int) $_GET['preview_id']; - if ( false == wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) ) + if ( false === wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) ) wp_die( __('You do not have permission to preview drafts.') ); add_filter('the_preview', '_set_preview'); diff --git a/wp-includes/version.php b/wp-includes/version.php index 5277cac0eb..4afe495497 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-alpha-32732'; +$wp_version = '4.3-alpha-32733'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-signup.php b/wp-signup.php index a519bcc0d6..7cef5447ff 100644 --- a/wp-signup.php +++ b/wp-signup.php @@ -7,7 +7,7 @@ add_action( 'wp_head', 'wp_no_robots' ); require( dirname( __FILE__ ) . '/wp-blog-header.php' ); -if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) == true ) { +if ( is_array( get_site_option( 'illegal_names' )) && isset( $_GET[ 'new' ] ) && in_array( $_GET[ 'new' ], get_site_option( 'illegal_names' ) ) ) { wp_redirect( network_home_url() ); die(); } @@ -700,9 +700,9 @@ if ( $active_signup == 'none' ) { do_action( 'preprocess_signup_form' ); if ( is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'blog' ) ) signup_another_blog($newblogname); - elseif ( is_user_logged_in() == false && ( $active_signup == 'all' || $active_signup == 'user' ) ) + elseif ( ! is_user_logged_in() && ( $active_signup == 'all' || $active_signup == 'user' ) ) signup_user( $newblogname, $user_email ); - elseif ( is_user_logged_in() == false && ( $active_signup == 'blog' ) ) + elseif ( ! is_user_logged_in() && ( $active_signup == 'blog' ) ) _e( 'Sorry, new registrations are not allowed at this time.' ); else _e( 'You are logged in already. No need to register again!' );