WordPress.org

Make WordPress Core

Opened 23 months ago

Last modified 2 days ago

#40035 assigned defect (bug)

Site registered date uses different time zone from last updated

Reported by: nnikolov Owned by: desrosj
Milestone: 5.1 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 23 months ago.
Site registered date uses different time zone than last updated
40035.diff (648 bytes) - added by desrosj 19 months ago.
40035.2.diff (1.4 KB) - added by desrosj 19 months ago.

Download all attachments as: .zip

Change History (9)

@nnikolov
23 months ago

Site registered date uses different time zone than last updated

@desrosj
19 months ago

#1 @desrosj
19 months 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
19 months ago

#2 @SergeyBiryukov
10 months ago

  • Milestone changed from Awaiting Review to 5.0

#3 @pento
3 months ago

  • Milestone changed from 5.0 to 5.1

#4 @spacedmonkey
10 days ago

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

#5 @pento
4 days ago

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

#6 @desrosj
2 days ago

  • Owner set to desrosj
  • Status changed from new to assigned
Note: See TracTickets for help on using tickets.