diff --git a/library/PostObject/Date/CachedTimestampResolver.php b/library/PostObject/Date/CachedTimestampResolver.php index a8d184324..d89b6e6de 100644 --- a/library/PostObject/Date/CachedTimestampResolver.php +++ b/library/PostObject/Date/CachedTimestampResolver.php @@ -28,7 +28,7 @@ public function __construct( * * @return int */ - public function resolve(): int + public function resolve(): ?int { $cacheKey = "{$this->postObject->getBlogId()}_{$this->postObject->getId()}"; diff --git a/library/PostObject/Date/TimestampResolver.php b/library/PostObject/Date/TimestampResolver.php index eee21ae15..84a740a4d 100644 --- a/library/PostObject/Date/TimestampResolver.php +++ b/library/PostObject/Date/TimestampResolver.php @@ -31,7 +31,7 @@ public function __construct( * * @return int */ - public function resolve(): int + public function resolve(): ?int { $archiveDateSetting = $this->archiveDateSetting->resolve(); @@ -39,13 +39,17 @@ public function resolve(): int return $this->getDefaultTimestamp($archiveDateSetting); } + if ($archiveDateSetting === 'none') { + return null; + } + return $this->getDateMetaValue($archiveDateSetting); } /** * Get the date meta value. */ - private function getDateMetaValue(string $archiveDateSetting): int + private function getDateMetaValue(string $archiveDateSetting): ?int { $metaValue = $this->wpService->getPostMeta($this->postObject->getId(), $archiveDateSetting, true); @@ -53,7 +57,7 @@ private function getDateMetaValue(string $archiveDateSetting): int return strtotime($metaValue); } - return 0; + return null; } /** diff --git a/library/PostObject/Date/TimestampResolverInterface.php b/library/PostObject/Date/TimestampResolverInterface.php index 14d7e5e92..7e51c5041 100644 --- a/library/PostObject/Date/TimestampResolverInterface.php +++ b/library/PostObject/Date/TimestampResolverInterface.php @@ -9,5 +9,5 @@ interface TimestampResolverInterface * * @return int */ - public function resolve(): int; + public function resolve(): ?int; } diff --git a/library/PostObject/Decorators/BackwardsCompatiblePostObject.php b/library/PostObject/Decorators/BackwardsCompatiblePostObject.php index 371d95b5d..35f2cbc34 100644 --- a/library/PostObject/Decorators/BackwardsCompatiblePostObject.php +++ b/library/PostObject/Decorators/BackwardsCompatiblePostObject.php @@ -135,7 +135,7 @@ public function getModifiedTime(bool $gmt = false): int /** * @inheritDoc */ - public function getArchiveDateTimestamp(): int + public function getArchiveDateTimestamp(): ?int { return $this->postObject->getArchiveDateTimestamp(); } diff --git a/library/PostObject/Decorators/IconResolvingPostObject.php b/library/PostObject/Decorators/IconResolvingPostObject.php index fe687c9a6..a994ff4f9 100644 --- a/library/PostObject/Decorators/IconResolvingPostObject.php +++ b/library/PostObject/Decorators/IconResolvingPostObject.php @@ -93,7 +93,7 @@ public function getModifiedTime(bool $gmt = false): int /** * @inheritDoc */ - public function getArchiveDateTimestamp(): int + public function getArchiveDateTimestamp(): ?int { return $this->postObject->getArchiveDateTimestamp(); } diff --git a/library/PostObject/Decorators/PostObjectArchiveDateFormat.php b/library/PostObject/Decorators/PostObjectArchiveDateFormat.php index 2bd7a4126..c6cb6f4bf 100644 --- a/library/PostObject/Decorators/PostObjectArchiveDateFormat.php +++ b/library/PostObject/Decorators/PostObjectArchiveDateFormat.php @@ -103,7 +103,7 @@ public function getModifiedTime(bool $gmt = false): int /** * @inheritDoc */ - public function getArchiveDateTimestamp(): int + public function getArchiveDateTimestamp(): ?int { return $this->postObject->getArchiveDateTimestamp(); } diff --git a/library/PostObject/Decorators/PostObjectArchiveDateTimestamp.php b/library/PostObject/Decorators/PostObjectArchiveDateTimestamp.php index 3f8325ee2..06ef8d1f8 100644 --- a/library/PostObject/Decorators/PostObjectArchiveDateTimestamp.php +++ b/library/PostObject/Decorators/PostObjectArchiveDateTimestamp.php @@ -103,7 +103,7 @@ public function getModifiedTime(bool $gmt = false): int /** * @inheritDoc */ - public function getArchiveDateTimestamp(): int + public function getArchiveDateTimestamp(): ?int { return $this->timestampResolver->resolve(); } diff --git a/library/PostObject/Decorators/PostObjectFromOtherBlog.php b/library/PostObject/Decorators/PostObjectFromOtherBlog.php index 31cc4c467..da508beb8 100644 --- a/library/PostObject/Decorators/PostObjectFromOtherBlog.php +++ b/library/PostObject/Decorators/PostObjectFromOtherBlog.php @@ -126,7 +126,7 @@ public function getModifiedTime(bool $gmt = false): int /** * @inheritDoc */ - public function getArchiveDateTimestamp(): int + public function getArchiveDateTimestamp(): ?int { return $this->postObject->getArchiveDateTimestamp(); } diff --git a/library/PostObject/Decorators/PostObjectFromWpPost.php b/library/PostObject/Decorators/PostObjectFromWpPost.php index 2b8c5146e..5aa8804a0 100644 --- a/library/PostObject/Decorators/PostObjectFromWpPost.php +++ b/library/PostObject/Decorators/PostObjectFromWpPost.php @@ -98,7 +98,7 @@ public function getModifiedTime(bool $gmt = false): int /** * @inheritDoc */ - public function getArchiveDateTimestamp(): int + public function getArchiveDateTimestamp(): ?int { return $this->postObject->getArchiveDateTimestamp(); } diff --git a/library/PostObject/Decorators/PostObjectWithSeoRedirect.php b/library/PostObject/Decorators/PostObjectWithSeoRedirect.php index 2b2a4f1ea..f4a1beb1c 100644 --- a/library/PostObject/Decorators/PostObjectWithSeoRedirect.php +++ b/library/PostObject/Decorators/PostObjectWithSeoRedirect.php @@ -107,7 +107,7 @@ public function getModifiedTime(bool $gmt = false): int /** * @inheritDoc */ - public function getArchiveDateTimestamp(): int + public function getArchiveDateTimestamp(): ?int { return $this->postObject->getArchiveDateTimestamp(); } diff --git a/library/PostObject/PostObject.php b/library/PostObject/PostObject.php index fa7d8f4d7..d4590202f 100644 --- a/library/PostObject/PostObject.php +++ b/library/PostObject/PostObject.php @@ -93,9 +93,9 @@ public function getModifiedTime(bool $gmt = false): int /** * @inheritDoc */ - public function getArchiveDateTimestamp(): int + public function getArchiveDateTimestamp(): ?int { - return 0; + return null; } /** diff --git a/library/PostObject/PostObject.test.php b/library/PostObject/PostObject.test.php index 4325195d0..ed19bf917 100644 --- a/library/PostObject/PostObject.test.php +++ b/library/PostObject/PostObject.test.php @@ -79,9 +79,9 @@ public function testGetBlogIdReturns1() /** * @testdox getArchiveDateTimestamp() returns 0 */ - public function testGetArchiveDateTimestampReturns0() + public function testGetArchiveDateTimestampReturnsNull() { - $this->assertEquals(0, $this->instance->getArchiveDateTimestamp()); + $this->assertEquals(null, $this->instance->getArchiveDateTimestamp()); } /** diff --git a/library/PostObject/PostObjectInterface.php b/library/PostObject/PostObjectInterface.php index e7249c64f..1782ca248 100644 --- a/library/PostObject/PostObjectInterface.php +++ b/library/PostObject/PostObjectInterface.php @@ -78,7 +78,7 @@ public function getModifiedTime(bool $gmt = false): int; * * @return int */ - public function getArchiveDateTimestamp(): int; + public function getArchiveDateTimestamp(): ?int; /** * Get the post object date format.