XF 2.2 Clear cache on add-on uninstallation

FoxSecrets

Active member
Whatever custom fields on templates, css, images or reactions I create on my add-on, they remain on uninstallation even removing all the table data . When installing it again they are all still there, so I presume that's coming from the cache, but I tried clearing browser cache but didn't work. I see some posts about maxcdn but this is something the user will not do it when using the add-on.

So how to properly clear the cache (by code) on uninstallation?
 
Last edited:
How are these changes applied to begin with? Be sure to set the add-on correctly for any template modifications or new templates so they can be removed appropriately.
 
The changes are applied by the user, using the add-on (e.g. reactions).
What you mean about 'correctly set'? Can you give an example?
 
Do you mean records for custom content types? See \XF\Install\InstallHelperTrait::uninstallContentTypeData, which you can call in an uninstall step:

PHP:
public function uninstallStep1(): void
{
    $this->uninstallContentTypeData(['some_content_type', 'some_other_content_type']);
}
 
Yes, records not only for custom content types, but also custom fields.

Regarding custom types, I've deleted this way (also the related entries in other tables). So is that wrong?
Code:
public function uninstallStep5()
{
    $db = $this->db();
    $db->delete('xf_reaction_content', 'content_type = ?', 'user_profile');
}

And for the custom fields, how to clear its cache? Any special method?
 
Last edited:
Regarding custom types, I've deleted this way, so that's wrong?
Not necessarily, but I'd recommend just using the built-in method as then you don't have to concern yourself much if you wind up implementing additional content type handlers in the future.

And for the custom fields, how to clear its cache? Any special method?
Likely not. You can use the entity system to delete them which may rebuild caches automatically, or if you do delete them manually (with a regular delete query) then you should also trigger the rebuilds manually.
 
Top Bottom