From 2adb62314f4f5d72ba210201538e08d51bcff991 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Sun, 18 Oct 2020 08:18:56 +0200
Subject: [PATCH] QA: remove assumption in code
Use a more stable condition.
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".
---
src/wp-includes/ms-functions.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php
index 65ee3d253d..0ad1f219a8 100644
a
|
b
|
function wpmu_validate_user_signup( $user_name, $user_email ) { |
543 | 543 | |
544 | 544 | // Has someone already signed up for this username? |
545 | 545 | $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name ) ); |
546 | | if ( null != $signup ) { |
| 546 | if ( $signup instanceof stdClass ) { |
547 | 547 | $registered_at = mysql2date( 'U', $signup->registered ); |
548 | 548 | $now = time(); |
549 | 549 | $diff = $now - $registered_at; |
… |
… |
function wpmu_validate_user_signup( $user_name, $user_email ) { |
556 | 556 | } |
557 | 557 | |
558 | 558 | $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email ) ); |
559 | | if ( null != $signup ) { |
| 559 | if ( $signup instanceof stdClass ) { |
560 | 560 | $diff = time() - mysql2date( 'U', $signup->registered ); |
561 | 561 | // If registered more than two days ago, cancel registration and let this signup go through. |
562 | 562 | if ( $diff > 2 * DAY_IN_SECONDS ) { |