X Tutup
Skip to content

Fix ExpireSharesJob so that it only expires shares that expired yesterday or earlier#38775

Merged
phil-davis merged 1 commit intomasterfrom
fix-ExpireSharesJob
May 26, 2021
Merged

Fix ExpireSharesJob so that it only expires shares that expired yesterday or earlier#38775
phil-davis merged 1 commit intomasterfrom
fix-ExpireSharesJob

Conversation

@phil-davis
Copy link
Contributor

@phil-davis phil-davis commented May 25, 2021

Description

ExpireSharesJob is currently deleting shares that have an expiration date in the past of "now". For example, if the job runs at 2021-05-25:11:30 then a share that has an expiration date set to "2021-05-25" will be "expired" and get removed. But actually the "meaning" of expiring on "2021-05-25" is understood to be that the share works all of that day, right up to and including "2021-05-25:23:59:59"

https://github.com/owncloud/core/blob/master/lib/private/Share20/Manager.php#L185 has the real-time logic of this:

	private static function shareHasExpired($share) {
		$expirationDate = $share->getExpirationDate();
		return ($expirationDate !== null) && ($expirationDate < new \DateTime("today"));
	}

That compares the expiration date of the share to the "zero" hour of "today", and only considers the share expired if the expiration date is strictly less than the beginning of "today". So a share that has an expiration date "today" will not actually expire until the next day starts.

This PR adjusts ExpireSharesJob so that it uses the same logic.

Related Issue

How Has This Been Tested?

Unit test.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@phil-davis phil-davis self-assigned this May 25, 2021
@update-docs
Copy link

update-docs bot commented May 25, 2021

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@phil-davis phil-davis force-pushed the fix-ExpireSharesJob branch from 122b338 to a5e6f4b Compare May 25, 2021 13:27
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@micbar micbar left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup