Skip to content

Commit

Permalink
Merge pull request #3 from sitegeist/mficzel-ignore-last-modication
Browse files Browse the repository at this point in the history
BUGFIX: Ignore lastModification in favor of creation and publicationDates ZombieDetector.php
  • Loading branch information
mficzel authored Jul 1, 2024
2 parents 7d179ca + e31fc03 commit 2070028
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions Classes/Domain/ZombieDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ public function isZombie(NodeInterface $node): bool

$latestAllowedTimestamp = time() - $this->zombificationPeriod;

/** @var \DateTime|null $lastModificationDateTime */
$lastModificationDateTime = $node->getNodeData()->getLastModificationDateTime();
$lastModificationTimestamp = $lastModificationDateTime?->getTimestamp();

/** @var \DateTime|null $lastPublicationDateTime */
$lastPublicationDateTime = $node->getNodeData()->getLastPublicationDateTime();
$lastPublicationTimestamp = $lastPublicationDateTime?->getTimestamp();

/** @var \DateTime|null $creationDateTime */
$creationDateTime = $node->getNodeData()->getCreationDateTime();
$creationTimestamp = $creationDateTime?->getTimestamp();

if (
($lastModificationTimestamp === null || $lastModificationTimestamp < $latestAllowedTimestamp)
&& ($lastPublicationTimestamp === null || $lastPublicationTimestamp < $latestAllowedTimestamp)
($lastPublicationTimestamp !== null && $lastPublicationTimestamp < $latestAllowedTimestamp)
|| ($lastPublicationTimestamp === null && $creationTimestamp < $latestAllowedTimestamp)
) {
return true;
}
Expand All @@ -55,18 +55,17 @@ public function isZombieThatHasToBeDestroyed(NodeInterface $node): bool

$latestAllowedTimestamp = time() - $this->zombificationPeriod - $this->destructionPeriod;

/** @var \DateTime|null $lastModificationDateTime */
$lastModificationDateTime = $node->getNodeData()->getLastModificationDateTime();
$lastModificationTimestamp = $lastModificationDateTime?->getTimestamp();

/** @var \DateTime|null $lastPublicationDateTime */
$lastPublicationDateTime = $node->getNodeData()->getLastPublicationDateTime();
$lastPublicationTimestamp = $lastPublicationDateTime?->getTimestamp();

/** @var \DateTime|null $creationDateTime */
$creationDateTime = $node->getNodeData()->getCreationDateTime();
$creationTimestamp = $creationDateTime?->getTimestamp();

if (
$node->isVisible() === false
&& ($lastModificationTimestamp === null || $lastModificationTimestamp < $latestAllowedTimestamp)
&& ($lastPublicationTimestamp === null || $lastPublicationTimestamp < $latestAllowedTimestamp)
($lastPublicationTimestamp !== null && $lastPublicationTimestamp < $latestAllowedTimestamp)
|| ($lastPublicationTimestamp === null && $creationTimestamp < $latestAllowedTimestamp)
) {
return true;
}
Expand Down

0 comments on commit 2070028

Please sign in to comment.