File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -214,9 +214,19 @@ 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+
220230 $ tagsItems = $ this ->getItems ($ this ->getTagKeys ($ item ->getTags ()));
221231
222232 foreach ($ tagsItems as $ tagsItem ) {
@@ -241,6 +251,7 @@ public function driverWriteTags(ExtendedCacheItemInterface $item)
241251 $ tagsItem ->expiresAt ($ item ->getExpirationDate ());
242252 }
243253 $ this ->driverWrite ($ tagsItem );
254+ $ tagsItem ->setHit (true );
244255 }
245256
246257 /**
@@ -265,6 +276,7 @@ public function driverWriteTags(ExtendedCacheItemInterface $item)
265276 if (count ($ data )) {
266277 $ tagsItem ->expiresAt (max ($ data ));
267278 $ this ->driverWrite ($ tagsItem );
279+ $ tagsItem ->setHit (true );
268280 } else {
269281 $ this ->driverDelete ($ tagsItem );
270282 }
You can’t perform that action at this time.
0 commit comments