keycdn / cache-enabler

A lightweight caching plugin for WordPress that makes your website faster by generating static HTML files.
https://wordpress.org/plugins/cache-enabler/
123 stars 46 forks source link

update validation for filters and page contents #299

Closed coreykn closed 2 years ago

coreykn commented 2 years ago

Update Cache_Enabler_Disk::create_cache_file() to validate the page contents again before maybe compressing and then saving the new cache file. This is needed because the page contents can be modified between first checking if they're cacheable and then actually creating the cached file (through a filter, HTML minification, or WebP conversion). This should help prevent Cache Enabler from odd failures or conflicts, such as in https://wordpress.org/support/?p=14373540.

Add type casts to the following hooks:

FYI, eventually there will be better return handling here (along with other parts of the code base), allowing Cache Enabler to let users know why the cached file creation failed (which is incredibly rare).