WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#44403 closed defect (bug) (duplicate)

WP_Error object is not returned. Only assigned to a variable

Reported by: subrataemfluence Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.1
Component: Users Keywords: has-patch
Focuses: Cc:

Description

Function: wp_validate_user_request_key
File: wp-includes/user.php
Line no.: 3512

According to the doc comment the above function should return wither a boolean value or a WP_Error object.

* @return bool|WP_Error WP_Error on failure, true on success.

At line number 3512 the WP_Error object is stored in a variable but never returned.

<?php
...
if ( ! $wp_hasher->CheckPassword( $key, $saved_key ) ) {
   return new WP_Error( 'invalid_key', __( 'Invalid key' ) );
}

if ( ! $expiration_time || time() > $expiration_time ) {
   $return = new WP_Error( 'expired_key', __( 'The confirmation email has expired.' ) ); // Line no. 3512. The new error object was never returned.
}

return true;

Shouldn't it be

<?php
if ( ! $expiration_time || time() > $expiration_time ) {
   return new WP_Error( 'expired_key', __( 'The confirmation email has expired.' ) );
}

like the code block just above it?

I am uploading a proposed patch for this. Please let me know if this works.

Attachments (1)

44403.diff (465 bytes) - added by subrataemfluence 2 years ago.

Download all attachments as: .zip

Change History (5)

#1 @subrataemfluence
2 years ago

  • Keywords has-patch added; needs-patch removed
  • Type changed from enhancement to defect (bug)

#2 @swissspidy
2 years ago

  • Milestone changed from Awaiting Review to 5.0

#3 @itowhid06
2 years ago

This has already been reported and fixed. Please refer to the following ticket.
https://core.trac.wordpress.org/ticket/44298

#4 @johnbillion
2 years ago

  • Milestone 5.0 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #44298.

Note: See TracTickets for help on using tickets.