Skip to content

feat(share): save date and time for expiration - #43428

Merged
Altahrim merged 1 commit into
masterfrom
feat/share-expiration-with-time
Feb 26, 2024
Merged

feat(share): save date and time for expiration#43428
Altahrim merged 1 commit into
masterfrom
feat/share-expiration-with-time

Conversation

@Altahrim

@AltahrimAltahrim commented Feb 7, 2024

Copy link
Copy Markdown
Collaborator

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

@AltahrimAltahrim self-assigned this Feb 8, 2024
@AltahrimAltahrim added the 2. developing Work in progress label Feb 8, 2024
@AltahrimAltahrim added this to the Nextcloud 29 milestone Feb 8, 2024
@Altahrim
Altahrimforce-pushed the feat/share-expiration-with-time branch 7 times, most recently from 41e359e to 719eed6CompareFebruary 9, 2024 08:02
@Altahrim
Altahrim requested review from a team, ArtificialOwl, icewind1991 and nfebe and removed request for a teamFebruary 9, 2024 08:20
@AltahrimAltahrim added 3. to review Waiting for reviews feature: sharing and removed 2. developing Work in progress labels Feb 9, 2024
@Altahrim
Altahrim marked this pull request as ready for review February 9, 2024 08:20
@Altahrim

Copy link
Copy Markdown
CollaboratorAuthor

/backport to stable28

@Altahrim

Copy link
Copy Markdown
CollaboratorAuthor

/backport to stable27

@Altahrim

Copy link
Copy Markdown
CollaboratorAuthor

/backport to stable26

Comment threadapps/files_sharing/lib/Controller/ShareAPIController.php Outdated
@Altahrim
Altahrimforce-pushed the feat/share-expiration-with-time branch 6 times, most recently from e019241 to ceebc38CompareFebruary 13, 2024 16:28
@Altahrim
Altahrimforce-pushed the feat/share-expiration-with-time branch from cca99e8 to e9733d0CompareFebruary 19, 2024 09:13
@AltahrimAltahrim added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Feb 19, 2024
@Altahrim
Altahrimforce-pushed the feat/share-expiration-with-time branch from e9733d0 to a05a877CompareFebruary 19, 2024 10:33
@Altahrim
Altahrimforce-pushed the feat/share-expiration-with-time branch from a05a877 to bc00614CompareFebruary 20, 2024 13:30
@AltahrimAltahrim added 2. developing Work in progress 3. to review Waiting for reviews feature: ldap and removed 2. developing Work in progress feature: ldap labels Feb 20, 2024

$expiration = $share->getExpirationDate();
if ($expiration !== null) {
$expiration->setTimezone($this->dateTimeZone->getTimeZone());

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
CollaboratorAuthor

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.

Comment threadapps/files_sharing/lib/Controller/ShareAPIController.php Outdated
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>
@Altahrim
Altahrimforce-pushed the feat/share-expiration-with-time branch from bc00614 to 01983d5CompareFebruary 22, 2024 10:26
@AltahrimAltahrim added the php Pull requests that update Php code label Feb 22, 2024
}

// Use server timezone to store the date
$date->setTimezone(new \DateTimeZone(date_default_timezone_get()));

Copy link
Copy Markdown
Contributor

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)

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsfeature: sharingphpPull requests that update Php code

Projects

Archived in project

6 participants

@Altahrim@artonge@icewind1991@susnux@github-advanced-security@come-nc