Coding Standards: Use more specific checks for $wpdb->get_row() results.

If `$wpdb->get_row()` is successful and the `$output` parameter has not been set, the output will be an instance of `stdClass`, so test to confirm that instead of testing against "not null".

This affects:
* `wpmu_validate_user_signup()`
* `wpmu_validate_blog_signup()`

Props jrf.
See #50767.
Built from https://develop.svn.wordpress.org/trunk@49206


git-svn-id: http://core.svn.wordpress.org/trunk@48968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-10-19 20:20:04 +00:00
parent 9d13ae60e4
commit fbc1622741
2 changed files with 4 additions and 4 deletions

View File

@ -543,7 +543,7 @@ function wpmu_validate_user_signup( $user_name, $user_email ) {
// Has someone already signed up for this username? // Has someone already signed up for this username?
$signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name ) ); $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name ) );
if ( null != $signup ) { if ( $signup instanceof stdClass ) {
$registered_at = mysql2date( 'U', $signup->registered ); $registered_at = mysql2date( 'U', $signup->registered );
$now = time(); $now = time();
$diff = $now - $registered_at; $diff = $now - $registered_at;
@ -556,7 +556,7 @@ function wpmu_validate_user_signup( $user_name, $user_email ) {
} }
$signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email ) ); $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email ) );
if ( null != $signup ) { if ( $signup instanceof stdClass ) {
$diff = time() - mysql2date( 'U', $signup->registered ); $diff = time() - mysql2date( 'U', $signup->registered );
// If registered more than two days ago, cancel registration and let this signup go through. // If registered more than two days ago, cancel registration and let this signup go through.
if ( $diff > 2 * DAY_IN_SECONDS ) { if ( $diff > 2 * DAY_IN_SECONDS ) {
@ -724,7 +724,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
// Has someone already signed up for this domain? // Has someone already signed up for this domain?
// TODO: Check email too? // TODO: Check email too?
$signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path ) ); $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path ) );
if ( ! empty( $signup ) ) { if ( $signup instanceof stdClass ) {
$diff = time() - mysql2date( 'U', $signup->registered ); $diff = time() - mysql2date( 'U', $signup->registered );
// If registered more than two days ago, cancel registration and let this signup go through. // If registered more than two days ago, cancel registration and let this signup go through.
if ( $diff > 2 * DAY_IN_SECONDS ) { if ( $diff > 2 * DAY_IN_SECONDS ) {

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.6-alpha-49205'; $wp_version = '5.6-alpha-49206';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.