-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(share): save date and time for expiration #43428
Conversation
41e359e
to
719eed6
Compare
/backport to stable28 |
/backport to stable27 |
/backport to stable26 |
e019241
to
ceebc38
Compare
cca99e8
to
e9733d0
Compare
e9733d0
to
a05a877
Compare
a05a877
to
bc00614
Compare
@@ -240,6 +240,7 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array | |||
|
|||
$expiration = $share->getExpirationDate(); | |||
if ($expiration !== null) { | |||
$expiration->setTimezone($this->dateTimeZone->getTimeZone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 <[email protected]>
bc00614
to
01983d5
Compare
} catch (\Exception $e) { | ||
throw new \Exception('Invalid date. Format must be YYYY-MM-DD'); | ||
} | ||
|
||
// Use server timezone to store the date | ||
$date->setTimezone(new \DateTimeZone(date_default_timezone_get())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always UTC (see base.php)
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