Fix S3 backup list times shifted by the site's UTC offset (shown twice-offset in history tables)#239
Open
chata wants to merge 1 commit into
Open
Conversation
BackWPup_Destination_S3::file_get_list() converts the S3 object's LastModified (UTC) to a Unix timestamp and then adds the site's gmt_offset to it. Unix timestamps are timezone-independent, so this shifts the epoch value into the future for sites east of UTC. Both the new backups history table (components/table-row-backups.php) and the legacy backups page (inc/class-page-backups.php) format this value with wp_date(), which already converts to the site timezone. The pre-shifted timestamp therefore gets the offset applied twice: on a UTC+9 site every S3/R2 backup is displayed 9 hours in the future (e.g. a backup taken at 13:40 JST shows as 10:40 PM), while backups stored in the local folder destination display correctly. Dropping the offset keeps retention pruning intact ( keys shift uniformly, so their order is unchanged) and makes both tables show the true backup time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #240
Description
BackWPup_Destination_S3::file_update_list()converts the S3 object'sLastModified(UTC) into a Unix timestamp and then adds the site'sgmt_offset:Unix timestamps are timezone-independent, so this shifts the epoch value into the future for sites east of UTC.
All three consumers of this value format it with
wp_date(), which already converts the epoch to the site timezone:components/table-row-backups.php(lines 9-10)inc/class-page-backups.php(column_time())$files[$filecounter]['time']within the same method, later rendered throughwp_date()The offset therefore gets applied twice. On a UTC+9 (Asia/Tokyo) site, every backup stored on an S3-compatible destination is displayed 9 hours in the future: a scheduled backup that ran at 0:00 JST shows as "9:00 AM", a manual backup taken at 1:40 PM shows as "10:40 PM". Backups stored on the local folder destination display correctly, which makes the S3 rows look inconsistent next to them.
Fix
Drop the
gmt_offsetaddition and keep the true epoch. This makes all three views show the correct backup time. It also brings S3 in line with the other remote destinations (Dropbox, MS Azure, RSC), which already use the raw epoch without an offset.Retention pruning is unaffected:
$backupfilelistis keyed by$changetimeonly for sorting, and removing a uniform shift does not change the ordering.How to reproduce
Tested on BackWPup 5.7.4 / WordPress with PHP 8.4 against Cloudflare R2 (S3-compatible).