Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix DateTime constructor calls with null
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Nov 23, 2021
commit 3a1b3745eb8e43eaa830bdeb9fe53a2de70349f0
2 changes: 1 addition & 1 deletion lib/private/Log/LogDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function logDetails(string $app, $message, int $level): array {
}
$time = \DateTime::createFromFormat("U.u", number_format(microtime(true), 4, ".", ""));
if ($time === false) {
$time = new \DateTime(null, $timezone);
$time = new \DateTime('now', $timezone);
} else {
// apply timezone if $time is created from UNIX timestamp
$time->setTimezone($timezone);
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/AppFramework/Http/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected function setUp(): void {

$this->response = $this->createMock(Response::class);

$this->lastModified = new \DateTime(null, new \DateTimeZone('GMT'));
$this->lastModified = new \DateTime('now', new \DateTimeZone('GMT'));
$this->etag = 'hi';
}

Expand Down
6 changes: 3 additions & 3 deletions tests/lib/AppFramework/Http/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function testGetEtag() {


public function testGetLastModified() {
$lastModified = new \DateTime(null, new \DateTimeZone('GMT'));
$lastModified = new \DateTime('now', new \DateTimeZone('GMT'));
$lastModified->setTimestamp(1);
$this->childResponse->setLastModified($lastModified);
$this->assertEquals($lastModified, $this->childResponse->getLastModified());
Expand Down Expand Up @@ -252,15 +252,15 @@ public function testCacheSeconds() {


public function testEtagLastModifiedHeaders() {
$lastModified = new \DateTime(null, new \DateTimeZone('GMT'));
$lastModified = new \DateTime('now', new \DateTimeZone('GMT'));
$lastModified->setTimestamp(1);
$this->childResponse->setLastModified($lastModified);
$headers = $this->childResponse->getHeaders();
$this->assertEquals('Thu, 01 Jan 1970 00:00:01 +0000', $headers['Last-Modified']);
}

public function testChainability() {
$lastModified = new \DateTime(null, new \DateTimeZone('GMT'));
$lastModified = new \DateTime('now', new \DateTimeZone('GMT'));
$lastModified->setTimestamp(1);

$this->childResponse->setEtag('hi')
Expand Down