Skip to content

Commit 516dc92

Browse files
committed
Replace deprecated DateTimeInterface::RFC7231 with literal format string
DateTimeInterface::RFC7231 is deprecated in PHP 8.5 because the format hardcodes GMT timezone, ignoring the actual timezone of the instance. Since gmdate() is used here (always GMT), the behavior is unchanged. See: php/php-src#12989
1 parent 8e4ab37 commit 516dc92

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

src/DevEtagSetter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use BEAR\RepositoryModule\Annotation\HttpCache;
88
use BEAR\Resource\Request;
99
use BEAR\Resource\ResourceObject;
10-
use DateTimeInterface;
1110
use Override;
1211

1312
use function gmdate;
@@ -30,7 +29,7 @@ public function __invoke(ResourceObject $ro, int|null $time = null, HttpCache|nu
3029
// This is useful for debugging purposes.
3130
// Usually, the ETag is a hash of the resource view or body.
3231
$ro->headers[Header::ETAG] = $uriEtag;
33-
$ro->headers[Header::LAST_MODIFIED] = gmdate(DateTimeInterface::RFC7231, 0);
32+
$ro->headers[Header::LAST_MODIFIED] = gmdate('D, d M Y H:i:s \G\M\T', 0);
3433
$this->setCacheDependency($ro);
3534
}
3635

src/EtagSetter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use BEAR\RepositoryModule\Annotation\HttpCache;
88
use BEAR\Resource\Request;
99
use BEAR\Resource\ResourceObject;
10-
use DateTimeInterface;
1110
use Override;
1211

1312
use function assert;
@@ -38,7 +37,7 @@ public function __invoke(ResourceObject $ro, int|null $time = null, HttpCache|nu
3837

3938
$etag = $this->getEtag($ro, $httpCache);
4039
$ro->headers[Header::ETAG] = $etag;
41-
$ro->headers[Header::LAST_MODIFIED] = gmdate(DateTimeInterface::RFC7231, $time);
40+
$ro->headers[Header::LAST_MODIFIED] = gmdate('D, d M Y H:i:s \G\M\T', $time);
4241
$this->setCacheDependency($ro);
4342
}
4443

0 commit comments

Comments
 (0)