final attribute on the CURL class breaks caching plugin functionality. #802
Open
Description
As a hosting provider that provides tailored WordPress hosting for numerous clients we are often tasked with working around poorly written plugins and/or code that does not cache fetched results from external sources. As such we have developed a plugin that extends the Curl transport with a caching mechanism based on a whitelist of URLs.
As of the update to the 2.0.0 requests library, it is now impossible to do this anymore due to the use of the final keyword on the Curl class.
Here is how we were doing this:
// register our transport wrapper
Requests::add_transport('\HF\Cache\cURL');
// force our transport to load first
Requests::$transport[serialize(['ssl' => true ])] = '\HF\Cache\cURL';
Requests::$transport[serialize(['ssl' => false])] = '\HF\Cache\cURL';
Requests::$transport[serialize([] )] = '\HF\Cache\cURL';
Our class would then override the request method and either inherit the default functionality or respond with a cached value:
class cURL extends \Requests_Transport_cURL
{
public function request($url, $headers = array(), $data = array(), $options = array())
{
// custom caching logic here
// inherit default logic
return parent::request($url, $headers, $data, $options);
}
}
Instead we now get the fatal error:
Class HF\Cache\cURL may not inherit from final class (WpOrg\Requests\Transport\Curl)
Please remove the final attribute from the Curl class.