File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -214,9 +214,22 @@ public function getDriverName()
214214 /**
215215 * @param \phpFastCache\Cache\ExtendedCacheItemInterface $item
216216 * @return bool
217+ * @throws \LogicException
217218 */
218219 public function driverWriteTags (ExtendedCacheItemInterface $ item )
219220 {
221+ /**
222+ * Do not attempt to write tags
223+ * on tags item, it can leads
224+ * to an infinite recursive calls
225+ */
226+ if (strpos ($ item ->getKey (), self ::DRIVER_TAGS_KEY_PREFIX ) === 0 ){
227+ throw new \LogicException ('Trying to set tag(s) to an Tag item index: ' . $ item ->getKey ());
228+ }
229+
230+ /**
231+ * @var $tagsItems ExtendedCacheItemInterface[]
232+ */
220233 $ tagsItems = $ this ->getItems ($ this ->getTagKeys ($ item ->getTags ()));
221234
222235 foreach ($ tagsItems as $ tagsItem ) {
@@ -241,6 +254,7 @@ public function driverWriteTags(ExtendedCacheItemInterface $item)
241254 $ tagsItem ->expiresAt ($ item ->getExpirationDate ());
242255 }
243256 $ this ->driverWrite ($ tagsItem );
257+ $ tagsItem ->setHit (true );
244258 }
245259
246260 /**
@@ -265,6 +279,7 @@ public function driverWriteTags(ExtendedCacheItemInterface $item)
265279 if (count ($ data )) {
266280 $ tagsItem ->expiresAt (max ($ data ));
267281 $ this ->driverWrite ($ tagsItem );
282+ $ tagsItem ->setHit (true );
268283 } else {
269284 $ this ->driverDelete ($ tagsItem );
270285 }
You can’t perform that action at this time.
0 commit comments