Skip to content

fix(share): set password expiration time on email share creation (#66177) - #66219

Open
saiyyedfardeen wants to merge 2 commits into
nextcloud:masterfrom
saiyyedfardeen:fix-66177
Open

saiyyedfardeen wants to merge 2 commits into
nextcloud:masterfrom
saiyyedfardeen:fix-66177

Conversation

@saiyyedfardeen

Copy link
Copy Markdown

Summary

When 'sharing.enable_mail_link_password_expiration' is enabled in configuration, creating an email share (IShare::TYPE_EMAIL) with a password resulted in password_expiration_time being stored as NULL in the oc_share table.

Previously, expiration time calculation via setSharePasswordExpirationTime() was only triggered during password updates in Manager::updateSharePasswordIfNeeded(), and was missed in the initial share creation logic.

Solution

  • In lib/private/Share20/Manager.php::createShare(): Added a call to $this->setSharePasswordExpirationTime($share) inside the password hashing block for IShare::TYPE_EMAIL shares, ensuring the expiration timestamp is computed and persisted on creation.
  • In tests/lib/Share20/ManagerTest.php: Added unit test testCreateShareByMailWithPasswordSetsExpirationTime() to assert that newly created email shares with passwords obtain a valid \DateTimeInterface expiration instance.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

…tcloud#66177)

Signed-off-by: Fardeen Saiyyed <fardinsaiyyed@hotmail.com>
@saiyyedfardeen
saiyyedfardeen requested review from a team as code owners November 3, 2026 18:29
@saiyyedfardeen
saiyyedfardeen requested review from icewind1991, leftybournes, salmart-dev and sorbaugh and removed request for a team November 3, 2026 18:29
@susnux
susnux requested review from DerDreschner and provokateurin and removed request for salmart-dev and sorbaugh November 5, 2026 10:50
@susnux susnux added this to the Nextcloud 36 milestone Nov 5, 2026

@provokateurin provokateurin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👍

Comment thread tests/lib/Share20/ManagerTest.php Outdated
Comment on lines +3544 to +3549
->willReturnCallback(function (string $key, bool $default = false): bool {
if ($key === 'sharing.enable_share_mail') {
return true;
}
return $default;
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use willReturnMap instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is fixed now. Please check.

@DerDreschner DerDreschner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just the little willReturnMap change should be done before merging.

Additional context: Broken since #31965

@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Assisted-by: Antigravity:Gemini-3.8-Flash
Signed-off-by: Fardeen Saiyyed <fardinsaiyyed@hotmail.com>

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: password_expiration_time is not set on share creation

4 participants