Closed stklcode closed 1 month ago
It might seem little far fetched, but providing the function_exists
result as default filter parameter allows to implement some logic to define this function on demand, e.g.
add_filter( 'cachify_create_gzip_files', function ( $available ) {
if ( ! $available ) {
// Define or load anything that implements gzencode.
function gzencode( $data, $level ) {
return $data;
}
}
return true;
} );
In the current suggestion: Yes, you can still override the false
with a filter, if gzencode
is not available.
One might polyfill another compression routine on demand in the filter hook (see example above). Seems more of a theoretical possibility though.
But I'd be fine changing the logic again, so the filter is completely omitted if gzencode
is not available. No hard preference for either way.
I changed the logic, so if gzencode
is not available we disable the feature and do not execute the filter.
This is trivial to change again, but >99.9% should not need such tricky configurations.
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
If zlib PHP extension is not loaded and there is no substitute in place,
gzencode()
does not exist and generation of compressed files will fail.Add a simple
function_exists()
test to prevent this.