Make WordPress Core

Changeset 49206


Ignore:
Timestamp:
10/19/2020 08:18:44 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-functions.php

    r49130 r49206  
    544544    // Has someone already signed up for this username?
    545545    $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 ) {
    547547        $registered_at = mysql2date( 'U', $signup->registered );
    548548        $now           = time();
     
    557557
    558558    $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 ) {
    560560        $diff = time() - mysql2date( 'U', $signup->registered );
    561561        // If registered more than two days ago, cancel registration and let this signup go through.
     
    725725    // TODO: Check email too?
    726726    $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path ) );
    727     if ( ! empty( $signup ) ) {
     727    if ( $signup instanceof stdClass ) {
    728728        $diff = time() - mysql2date( 'U', $signup->registered );
    729729        // If registered more than two days ago, cancel registration and let this signup go through.
Note: See TracChangeset for help on using the changeset viewer.