Uh oh!
There was an error while loading. Please reload this page.
feat(share): save date and time for expiration - #43428
Conversation
41e359e to
719eed6CompareAltahrim
commented
Feb 9, 2024
/backport to stable28 |
Altahrim
commented
Feb 9, 2024
/backport to stable27 |
Altahrim
commented
Feb 9, 2024
/backport to stable26 |
Uh oh!
There was an error while loading. Please reload this page.
e019241 to
ceebc38Comparecca99e8 to
e9733d0Comparee9733d0 to
a05a877Comparea05a877 to
bc00614Compare| $expiration = $share->getExpirationDate(); | ||
| if ($expiration !== null) { | ||
| $expiration->setTimezone($this->dateTimeZone->getTimeZone()); |
There was a problem hiding this comment.
Am I right that the timezone is relative to the current user, logged in or not? So, in the case of a public share, the timezone of the current user will be used instead of the one from the share owner. Maybe this is only ever called from the owner perspective, so it might not be a problem.
There was a problem hiding this comment.
You are right.
It's mainly use for display, so an user will see the right expiration date for him, even if time will probably be false.
If a share expire at 00:00:00 UTC on day D, an user in UTC-2 will see D-1 00:00:00. Time is false but ensure API compatibility.
Uh oh!
There was an error while loading. Please reload this page.
Because of timezones, not saving time can lead to unexpected behaviour when sharing an item sooner than timezone offset Example: sharing a file before 9am when in UTC+9 Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
bc00614 to
01983d5Compare| } | ||
| // Use server timezone to store the date | ||
| $date->setTimezone(new \DateTimeZone(date_default_timezone_get())); |
Summary
When we store an expiration date for a share, we store only the date, without time.
If an user is in UTC + 9 and share a file before 9am, the server will consider the expiration date to be one day earlier (ie. D+6 instead of D+7). Then, the display is wrong.
To fix that, we have to store time.
Fix#43457
Fix#43243
Checklist