litespeedtech / lscache-drupal

LSCache Plugin for Drupal
GNU General Public License v3.0
14 stars 15 forks source link

fix #15: allow calling invalidateTags() multiple times with expected behavior #17

Closed lupupitkanen closed 4 years ago

lupupitkanen commented 4 years ago

The Drupal Cache::invalidateTags() function could be (and is typically) called multiple times during a single request/response. Original LSCacheTagsInvalidator::invalidateTags() did not take this into account, leading to unexpected cache purging behavior (cache was not purged).

As the LSCacheTagsInvalidator::invalidateTags() is only gathering invalidated tags and the actual cache purging is handled in LiteSpeedCacheSubscriber using response header, previous state of invalidateTags() should be remembered between calls.

This PR appends the cache tags to LSCacheTagsInvalidator::$tags instead overwriting it on every invalidateTags() call. Additionally the invalidateTags() now checks if LSCacheTagsInvalidator::$purgeAllByTags have been set previously and ensure it's not overwritten if set.