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
3 changes: 2 additions & 1 deletion apps/dav/lib/Provisioning/Apple/AppleProvisioningNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\DAV\Provisioning\Apple;

use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Constants;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\INode;
use Sabre\DAV\IProperties;
Expand Down Expand Up @@ -60,7 +61,7 @@ public function getProperties($properties) {

return [
'{DAV:}getcontentlength' => 42,
'{DAV:}getlastmodified' => $datetime->format(\DateTimeInterface::RFC7231),
'{DAV:}getlastmodified' => $datetime->format(Constants::DATE_RFC7231),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Middleware;
use OCP\Constants;
use OCP\IRequest;

class NotModifiedMiddleware extends Middleware {
Expand All @@ -27,7 +28,7 @@ public function afterController($controller, $methodName, Response $response) {
}

$modifiedSinceHeader = $this->request->getHeader('IF_MODIFIED_SINCE');
if ($modifiedSinceHeader !== '' && $response->getLastModified() !== null && trim($modifiedSinceHeader) === $response->getLastModified()->format(\DateTimeInterface::RFC7231)) {
if ($modifiedSinceHeader !== '' && $response->getLastModified() !== null && trim($modifiedSinceHeader) === $response->getLastModified()->format(Constants::DATE_RFC7231)) {
$response->setStatus(Http::STATUS_NOT_MODIFIED);
return $response;
}
Expand Down
5 changes: 3 additions & 2 deletions lib/public/AppFramework/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use OCP\AppFramework\Http;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Constants;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserSession;
Expand Down Expand Up @@ -98,7 +99,7 @@ public function cacheFor(int $cacheSeconds, bool $public = false, bool $immutabl
$time = \OCP\Server::get(ITimeFactory::class);
$expires->setTimestamp($time->getTime());
$expires->add(new \DateInterval('PT' . $cacheSeconds . 'S'));
$this->addHeader('Expires', $expires->format(\DateTimeInterface::RFC7231));
$this->addHeader('Expires', $expires->format(Constants::DATE_RFC7231));
} else {
$this->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
unset($this->headers['Expires']);
Expand Down Expand Up @@ -240,7 +241,7 @@ public function getHeaders() {
];

if ($this->lastModified) {
$mergeWith['Last-Modified'] = $this->lastModified->format(\DateTimeInterface::RFC7231);
$mergeWith['Last-Modified'] = $this->lastModified->format(Constants::DATE_RFC7231);
}

if ($this->ETag) {
Expand Down
8 changes: 8 additions & 0 deletions lib/public/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,12 @@ class Constants {
* cf. sharing.maxAutocompleteResults in config.sample.php.
*/
public const SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT = 25;

/**
* Replacement for the built-in `DATE_RFC7231` constant
* deprecated since PHP 8.5.
*
* @since 33.0.1
*/
public const DATE_RFC7231 = 'D, d M Y H:i:s \G\M\T';
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Response;
use OCP\Constants;
use OCP\IRequest;

class NotModifiedMiddlewareTest extends \Test\TestCase {
Expand Down Expand Up @@ -44,13 +45,13 @@ public static function dataModified(): array {
[null, '"etag"', null, '', false],
['etag', '"etag"', null, '', true],

[null, '', $now, $now->format(\DateTimeInterface::RFC7231), true],
[null, '', $now, $now->format(Constants::DATE_RFC7231), true],
[null, '', $now, $now->format(\DateTimeInterface::ATOM), false],
[null, '', null, $now->format(\DateTimeInterface::RFC7231), false],
[null, '', null, $now->format(Constants::DATE_RFC7231), false],
[null, '', $now, '', false],

['etag', '"etag"', $now, $now->format(\DateTimeInterface::ATOM), true],
['etag', '"etag"', $now, $now->format(\DateTimeInterface::RFC7231), true],
['etag', '"etag"', $now, $now->format(Constants::DATE_RFC7231), true],
];
}

Expand Down
Loading