Date/Time: Reduce explicit local current_time( 'timestamp' ) usage in favor of native PHP functions.

Timestamps don't carry any timezone information, using the intended format directly simplifies the logic and makes the code less confusing.

Props Rarst, jdgrimes.
See #40657.

git-svn-id: https://develop.svn.wordpress.org/trunk@44809 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2019-03-07 09:11:37 +00:00
parent 79a3abcb2a
commit 4b10390b7d
7 changed files with 31 additions and 32 deletions

View File

@@ -518,7 +518,7 @@ function wpmu_validate_user_signup( $user_name, $user_email ) {
$signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name ) );
if ( $signup != null ) {
$registered_at = mysql2date( 'U', $signup->registered );
$now = current_time( 'timestamp', true );
$now = time();
$diff = $now - $registered_at;
// If registered more than two days ago, cancel registration and let this signup go through.
if ( $diff > 2 * DAY_IN_SECONDS ) {
@@ -530,7 +530,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 ) );
if ( $signup != null ) {
$diff = current_time( 'timestamp', true ) - 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 ( $diff > 2 * DAY_IN_SECONDS ) {
$wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) );
@@ -688,7 +688,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
// Has someone already signed up for this domain?
$signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path ) ); // TODO: Check email too?
if ( ! empty( $signup ) ) {
$diff = current_time( 'timestamp', true ) - 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 ( $diff > 2 * DAY_IN_SECONDS ) {
$wpdb->delete(