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 | Owned by: | 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?
- Using WordPress 4.7.2 and a multisite installation log-in as Super Admin.
- Go to the General settings of the main network site and change your time zone to UTC+3 (or anything different from UTC).
- Go to Network admin -> Sites -> Add New, and create a new site.
- 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)
Change History (10)
#1
@
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.
Site registered date uses different time zone than last updated