Make WordPress Core

Opened 8 years ago

Closed 6 years ago

#40035 closed defect (bug) (duplicate)

Site registered date uses different time zone from last updated

Reported by: nnikolov's profile nnikolov Owned by: desrosj's profile desrosj
Milestone: Priority: normal
Severity: normal Version: 4.7.2
Component: Networks and Sites Keywords: has-patch has-unit-tests needs-refresh
Focuses: multisite Cc:

Description

The problem
In a multisite, when a new site is created, the registered date and time is stored using the time zone setting for the main network site, but the last updated date and time uses the GMT time. This inconsistency is confusing and also can lead to last updated time that is before the registered time, which is impossible.

How to reproduce?

  1. Using WordPress 4.7.2 and a multisite installation log-in as Super Admin.
  2. Go to the General settings of the main network site and change your time zone to UTC+3 (or anything different from UTC).
  3. Go to Network admin -> Sites -> Add New, and create a new site.
  4. Click Edit Site after it is created and see that the registered date and time is different from the last updated date and time (they should be the same).

How to fix?
The problem is on line 1330 in the file /wp-includes/ms-functions.php.
Currently the line is like this:

$result = $wpdb->insert( $wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );

Needs to be like this:

$result = $wpdb->insert( $wpdb->blogs, array('site_id' => $site_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql', true)) );

Attachments (3)

registered.png (33.6 KB) - added by nnikolov 8 years ago.
Site registered date uses different time zone than last updated
40035.diff (648 bytes) - added by desrosj 7 years ago.
40035.2.diff (1.4 KB) - added by desrosj 7 years ago.

Download all attachments as: .zip

Change History (10)

@nnikolov
8 years ago

Site registered date uses different time zone than last updated

@desrosj
7 years ago

#1 @desrosj
7 years ago

  • Keywords has-patch needs-unit-tests added

Hi @nnikolov, thanks for the detailed ticket. Welcome to Trac!

I was able to reproduce the issue locally. I can also confirm that your suggested fix solves the problem. 40035.diff is the needed patch.

It is not possible to write a unit test for this, though, until #41064 is fixed.

@desrosj
7 years ago

#2 @SergeyBiryukov
7 years ago

  • Milestone changed from Awaiting Review to 5.0

#3 @pento
6 years ago

  • Milestone changed from 5.0 to 5.1

#4 @spacedmonkey
6 years ago

@flixos90 This seems valid and has tests. I am happy for this to go in 5.1

#5 @pento
6 years ago

  • Keywords has-unit-tests needs-refresh added; needs-unit-tests removed

#6 @desrosj
6 years ago

  • Owner set to desrosj
  • Status changed from new to assigned

#7 @pento
6 years ago

  • Milestone 5.1 deleted
  • Resolution set to duplicate
  • Status changed from assigned to closed

This bug was fixed with the creation of wp_insert_site() in #40364.

Note: See TracTickets for help on using tickets.