WordPress.org

Make WordPress Core

Opened 15 months ago

Last modified 2 months ago

#40035 new defect (bug)

Site registered date uses different time zone from last updated

Reported by: nnikolov Owned by:
Milestone: 5.0 Priority: normal
Severity: normal Version: 4.7.2
Component: Networks and Sites Keywords: has-patch needs-unit-tests
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 15 months ago.
Site registered date uses different time zone than last updated
40035.diff (648 bytes) - added by desrosj 11 months ago.
40035.2.diff (1.4 KB) - added by desrosj 11 months ago.

Download all attachments as: .zip

Change History (5)

@nnikolov
15 months ago

Site registered date uses different time zone than last updated

@desrosj
11 months ago

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

#2 @SergeyBiryukov
2 months ago

  • Milestone changed from Awaiting Review to 5.0
Note: See TracTickets for help on using tickets.