mmikkel / CacheFlag-Craft

Flag and clear template caches
MIT License
36 stars 5 forks source link

Not working with Shortlist plugin #20

Closed Moorst closed 6 years ago

Moorst commented 6 years ago

Not sure why, but when trying to add to a Shortlist (using https://github.com/TopShelfCraft/Shortlist), Cacheflag is throwing an error;

Property "Craft\Shortlist_ItemModel.section" is not defined.

image

mmikkel commented 6 years ago

Huh, that was a really odd bug. What happens here, is that the Shortlist_ItemModel class returns "Entry" for the magic getter $element->elementType, where it should return the name of its actual (custom) element type, i.e. "ShortList_Item". Then, stuff chokes because CacheFlag attempts to read the non-existing section property for the ShortList_ItemModel instance (because it thinks it's an Entry).

Using the getter method $element->getElementType() returns the proper element type for the ShortList_ItemModel instance, so stuff seems to work now.

I just put up a patch w/ CacheFlag v. 1.1.11 – let me know if it fixes your issue @Moorst, and thanks for contributing!

Moorst commented 6 years ago

Working now, thanks!