[wp-trac] [WordPress Trac] #58091: Requests library update to 2.0.0 breaks plugin
WordPress Trac
noreply at wordpress.org
Wed Apr 5 06:26:12 UTC 2023
#58091: Requests library update to 2.0.0 breaks plugin
--------------------------------+-----------------------------
Reporter: gnif | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: External Libraries | Version: trunk
Severity: critical | Keywords:
Focuses: |
--------------------------------+-----------------------------
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.
{{{#!php
// 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.
{{{#!php
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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58091>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list