[wp-trac] [WordPress Trac] #55711: set_time_limit( 300 ); in Class WP_Upgrader causes crashes in PHP8 when hosting disables it
WordPress Trac
noreply at wordpress.org
Wed May 11 16:34:12 UTC 2022
#55711: set_time_limit( 300 ); in Class WP_Upgrader causes crashes in PHP8 when
hosting disables it
-----------------------------+------------------------------
Reporter: theode | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Upgrade/Install | Version: 5.9.3
Severity: critical | Resolution:
Keywords: | Focuses: administration
-----------------------------+------------------------------
Comment (by hellofromTonya):
I agree with @johnbillion. `function_exists( 'set_time_limit' )` would
guard against invoking the native PHP function when it's been disabled and
is not in memory.
The issue though is beyond just the `WP_Upgrader` class. Core has 10 total
instances of using `set_time_limit()`. Introducing a `wp_set_time_limit()`
wrapper function could encapsulate the code for reuse in each of these
instances.
How are other projects handling this?
SMTP and
[https://github.com/woocommerce/woocommerce/blob/33bea63963493cb3feb19c7ba4a49a3f186faff8/plugins/woocommerce/includes
/wc-core-functions.php#L1686-L1696 WooCommerce] offer slightly different
solutions.
* Both are checking the if `'set_time_limit`' is in `'disable_functions'`
ini list:
{{{#!php
false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' )
}}}
* WooCommerce goes further to also check `function_exists()` and
`'safe_mode'` (in the ini).
* SMTP uses the `@` though this will be ineffective in >= PHP 8.
Reference:
* https://www.php.net/manual/en/function.set-time-limit.php
* `wc_set_time_limit()` in WooCommerce
https://github.com/woocommerce/woocommerce/blob/33bea63963493cb3feb19c7ba4a49a3f186faff8/plugins/woocommerce/includes
/wc-core-functions.php#L1686-L1696
* SMTP https://core.trac.wordpress.org/browser/trunk/src/wp-
includes/PHPMailer/SMTP.php#L435-437
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55711#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list