Skip to content

Commit b5d59d7

Browse files
committed
Fixes caching issue
This change keeps the current cache allive if no value can be set otherwise
1 parent 5767ac8 commit b5d59d7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: src/module/Phpug/src/Phpug/Cache/Cache.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
use Phpug\Entity\Usergroup;
3535
use Phpug\Entity\Cache as CacheEntity;
36+
use DateTime;
3637
use Zend\ServiceManager\ServiceLocatorInterface;
3738

3839
class Cache implements CacheInterface
@@ -95,7 +96,11 @@ public function getCache()
9596
$cacheLifeTime = $config['phpug']['entity']['cache'][$this->type]['cacheLifeTime'];
9697
$cacheLifeTime = new \DateInterval($cacheLifeTime);
9798
if ($myCache->getLastChangeDate()->add($cacheLifeTime) < new \DateTime() || trim($myCache->getCache()) == '') {
98-
$myCache->setCache($this->populator->populate($this->usergroup, $this->serviceManager));
99+
$value = $this->populator->populate($this->usergroup, $this->serviceManager);
100+
if ($value) {
101+
$myCache->setCache($value);
102+
}
103+
$myCache->setLastChangeDate(new DateTime());
99104
$myCache = $this->makePersistent($myCache);
100105

101106
}

0 commit comments

Comments
 (0)