Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
$expiration = $share->getExpirationDate();
if ($expiration !== null) {
$expiration->setTimezone($this->dateTimeZone->getTimeZone());
$result['expiration'] = $expiration->format('Y-m-d 00:00:00');
$result['expiration'] = $expiration->format('Y-m-d H:i:s');
}

if ($share->getShareType() === IShare::TYPE_USER) {
Expand Down
8 changes: 4 additions & 4 deletions apps/files_sharing/tests/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ public function testUpdateShareExpireDate(): void {
$share1 = $this->shareManager->getShareById($share1->getFullId());

// date should be changed
$dateWithinRange->setTime(0, 0, 0);
$dateWithinRange->setTime(23, 59, 59);
$dateWithinRange->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$this->assertEquals($dateWithinRange, $share1->getExpirationDate());

Expand Down Expand Up @@ -1263,7 +1263,7 @@ public function testShareStorageMountPoint(): void {

public static function datesProvider() {
$date = new \DateTime();
$date->setTime(0, 0);
$date->setTime(23, 59, 59);
$date->add(new \DateInterval('P5D'));
$date->setTimezone(new \DateTimeZone(date_default_timezone_get()));

Expand Down Expand Up @@ -1325,14 +1325,14 @@ public function testCreatePublicLinkExpireDateValid(): void {

$data = $result->getData();
$this->assertTrue(is_string($data['token']));
$this->assertEquals($date->format('Y-m-d 00:00:00'), $data['expiration']);
$this->assertEquals($date->format('Y-m-d 23:59:59'), $data['expiration']);

// check for correct link
$url = Server::get(IURLGenerator::class)->getAbsoluteURL('/index.php/s/' . $data['token']);
$this->assertEquals($url, $data['url']);

$share = $this->shareManager->getShareById('ocinternal:' . $data['id']);
$date->setTime(0, 0, 0);
$date->setTime(23, 59, 59);
$this->assertEquals($date, $share->getExpirationDate());

$this->shareManager->deleteShare($share);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ public static function dataGetShare(): array {
$data['Folder shared with group'] = [$share, $expected, true];

// File shared by link with Expire
$expire = \DateTime::createFromFormat('Y-m-d h:i:s', '2000-01-02 01:02:03');
$expire = \DateTime::createFromFormat('Y-m-d H:i:s', '2000-01-02 23:59:59');
$share = [
'101',
IShare::TYPE_LINK,
Expand Down Expand Up @@ -807,7 +807,7 @@ public static function dataGetShare(): array {
'file_target' => 'target',
'file_parent' => 3,
'token' => 'token',
'expiration' => '2000-01-02 00:00:00',
'expiration' => '2000-01-02 23:59:59',
'permissions' => 4,
'attributes' => null,
'stime' => 5,
Expand Down Expand Up @@ -4504,7 +4504,7 @@ public static function dataFormatShare(): array {
'permissions' => 1,
'stime' => 946684862,
'parent' => null,
'expiration' => '2001-02-03 00:00:00',
'expiration' => '2001-02-03 04:05:06',
'token' => null,
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
Expand Down Expand Up @@ -4554,7 +4554,7 @@ public static function dataFormatShare(): array {
'permissions' => 1,
'stime' => 946684862,
'parent' => null,
'expiration' => '2001-02-03 00:00:00',
'expiration' => '2001-02-03 04:05:06',
'token' => null,
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
Expand Down
9 changes: 4 additions & 5 deletions apps/files_sharing/tests/SharesReminderJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,11 @@ public static function dataSharesReminder() {
$someMail = 'test@test.com';
$noExpirationDate = null;
$today = new \DateTime();
// For expiration dates, the time is always automatically set to zero by ShareAPIController
$today->setTime(0, 0);
$nearFuture = new \DateTime();
$nearFuture->setTimestamp($today->getTimestamp() + 86400 * 1);
// Expiration dates are set to end of day (23:59:59) by the Share Manager
$today->setTime(23, 59, 59);
$nearFuture = clone $today;
$farFuture = new \DateTime();
$farFuture->setTimestamp($today->getTimestamp() + 86400 * 2);
$farFuture->setTimestamp($today->getTimestamp() + 86400 * 1);
$permissionRead = Constants::PERMISSION_READ;
$permissionCreate = $permissionRead | Constants::PERMISSION_CREATE;
$permissionUpdate = $permissionRead | Constants::PERMISSION_UPDATE;
Expand Down
4 changes: 2 additions & 2 deletions build/integration/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public function isFieldInResponse($field, $contentExpected) {
$data = simplexml_load_string($this->response->getBody())->data[0];
if ((string)$field == 'expiration') {
if (!empty($contentExpected)) {
$contentExpected = date('Y-m-d', strtotime($contentExpected)) . ' 00:00:00';
$contentExpected = date('Y-m-d', strtotime($contentExpected)) . ' 23:59:59';
}
}
if (count($data->element) > 0) {
Expand Down Expand Up @@ -611,7 +611,7 @@ private function assertFieldIsInReturnedShare(string $field, string $contentExpe
}

if ($field === 'expiration' && !empty($contentExpected)) {
$contentExpected = date('Y-m-d', strtotime($contentExpected)) . ' 00:00:00';
$contentExpected = date('Y-m-d', strtotime($contentExpected)) . ' 23:59:59';
}

if ($contentExpected === 'A_NUMBER') {
Expand Down
12 changes: 6 additions & 6 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ protected function validateExpirationDateInternal(IShare $share): IShare {
if (!$share->getNoExpirationDate() || $isEnforced) {
if ($expirationDate !== null) {
$expirationDate->setTimezone($this->dateTimeZone->getTimeZone());
$expirationDate->setTime(0, 0, 0);
$expirationDate->setTime(23, 59, 59);

$date = new \DateTime('now', $this->dateTimeZone->getTimeZone());
$date->setTime(0, 0, 0);
Expand All @@ -321,7 +321,7 @@ protected function validateExpirationDateInternal(IShare $share): IShare {

if ($fullId === null && $expirationDate === null && $defaultExpireDate) {
$expirationDate = new \DateTime('now', $this->dateTimeZone->getTimeZone());
$expirationDate->setTime(0, 0, 0);
$expirationDate->setTime(23, 59, 59);
$days = (int)$this->config->getAppValue('core', $configProp, (string)$defaultExpireDays);
if ($days > $defaultExpireDays) {
$days = $defaultExpireDays;
Expand All @@ -336,7 +336,7 @@ protected function validateExpirationDateInternal(IShare $share): IShare {
}

$date = new \DateTime('now', $this->dateTimeZone->getTimeZone());
$date->setTime(0, 0, 0);
$date->setTime(23, 59, 59);
$date->add(new \DateInterval('P' . $defaultExpireDays . 'D'));
if ($date < $expirationDate) {
throw new GenericShareException($this->l->n('Cannot set expiration date more than %n day in the future', 'Cannot set expiration date more than %n days in the future', $defaultExpireDays), code: 404);
Expand Down Expand Up @@ -380,7 +380,7 @@ protected function validateExpirationDateLink(IShare $share): IShare {
if (!($share->getNoExpirationDate() && !$isEnforced)) {
if ($expirationDate !== null) {
$expirationDate->setTimezone($this->dateTimeZone->getTimeZone());
$expirationDate->setTime(0, 0, 0);
$expirationDate->setTime(23, 59, 59);

$date = new \DateTime('now', $this->dateTimeZone->getTimeZone());
$date->setTime(0, 0, 0);
Expand All @@ -399,7 +399,7 @@ protected function validateExpirationDateLink(IShare $share): IShare {

if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
$expirationDate = new \DateTime('now', $this->dateTimeZone->getTimeZone());
$expirationDate->setTime(0, 0, 0);
$expirationDate->setTime(23, 59, 59);

$days = (int)$this->config->getAppValue('core', 'link_defaultExpDays', (string)$this->shareApiLinkDefaultExpireDays());
if ($days > $this->shareApiLinkDefaultExpireDays()) {
Expand All @@ -415,7 +415,7 @@ protected function validateExpirationDateLink(IShare $share): IShare {
}

$date = new \DateTime('now', $this->dateTimeZone->getTimeZone());
$date->setTime(0, 0, 0);
$date->setTime(23, 59, 59);
$date->add(new \DateInterval('P' . $this->shareApiLinkDefaultExpireDays() . 'D'));
if ($date < $expirationDate) {
throw new GenericShareException(
Expand Down
Loading
Loading