Max_execution_time not working

Seams that what ever i do i cannot run a php script longer than 1800 seconds.

I have changed every php.ini.hbs file i can find. Restarted Local.
When checking the WordPress health page it looks correct with the new value.
Then i run an Updraft import and get this logged to my debug.log “PHP Fatal error: Maximum execution time of 1800 seconds exceeded in C:\Users\tobia\Local Sites\…\app\public\wp-content\plugins\updraftplus\includes\class-search-replace.php on line 232”

Tried PHP 8.2 and 8.3.


What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc


System Details

  • Local Version: Version 9.2.8+6882

  • Operating System (OS) and OS version: Windows 11


Hey @jpegtobbe - That’s quite a long time to try and set. If you’re trying to import a very large site/DB into Local you might have to do this manually instead. We have some steps on how to do this here with just the basic WP-Content and SQL files:

Manually Import a Local Site

Yes thanks, my solution was to do a manual import of the DB.

But it still a problem that you cannot run a script for more that 1800 seconds. Why doesnt it use the set values of the php settings file? PHP report the correct time but it still limits it to 1800 secs. Got to be a bug?

So you’re saying you set it higher, but it still tapped out at 1800 @jpegtobbe? I’m not aware of it being a set limit, but we can certainly look into it. Did you Stop and Restart your site after making changes to the php.ini.hbs file?

Yes thats correct. But the strange thing is PHP get reported (WP health stats) that the limit is what you have entered in your hbs-file. So it got to be Local thats cutting the script. Also, think i tried both Nginx and Apache.

@jpegtobbe The 1800 limit you’re seeing likely comes from your updraftplus plugin.

Plugins can override limits in php.ini, and the updraftplus code does that in many places, sometimes with the hard limit of 1800 you mentioned, for example:

/Users/user.name/Downloads/updraftplus/includes/migrator-lite.php
if (function_exists('set_time_limit')) @set_time_limit(1800);

… and other times with a UPDRAFTPLUS_SET_TIME_LIMIT env var:

/Users/user.name/Downloads/updraftplus/restorer.php:
if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);

You’d have to contact the developers to learn more about why it’s there. (You could also try find-replacing all instances of 1800 in the plugin to something higher to test the theory, although obviously take backups first and be careful not to change code outside the plugin.)


Full listing of set_time_limit in updraftplus that ripgrep found:

> rg set_time_limit updraftplus

updraftplus/restorer.php:		if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/restorer.php:		if (function_exists('set_time_limit')) @set_time_limit(1800);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/restorer.php:		if (function_exists('set_time_limit')) @set_time_limit(1800);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/restorer.php:		if (function_exists('set_time_limit')) @set_time_limit(1800);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- The call is speculative
updraftplus/updraftplus.php:// This is passed to set_time_limit() at various points, to try to maximise run-time. (UD resumes if it gets killed, but more in one stretch always helps). The effect of this varies according to the hosting setup - it can't necessarily always be controlled.
updraftplus/admin.php:		if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/admin.php:		if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/admin.php:		if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/admin.php:		if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/admin.php:		if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/admin.php:		if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/backup.php:		if (function_exists('set_time_limit')) set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);
updraftplus/backup.php:				if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/backup.php:			if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/backup.php:				if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/backup.php:					if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/central/bootstrap.php:		if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTCENTRAL_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/includes/class-wpadmin-commands.php:			if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/includes/class-storage-methods-interface.php:		if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/class-updraftplus.php:		if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/class-updraftplus.php:		if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/class-updraftplus.php:		if (function_exists('set_time_limit')) @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/class-updraftplus.php:		if (function_exists('set_time_limit')) @set_time_limit(900);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/class-updraftplus.php:		if (function_exists('set_time_limit')) @set_time_limit($dbscan_timeout);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/includes/migrator-lite.php:		if (function_exists('set_time_limit')) @set_time_limit(1800);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.
updraftplus/includes/migrator-lite.php:		if (function_exists('set_time_limit')) @set_time_limit(1800);// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Silenced to suppress errors that may arise because of the function.

Oh yeah it sure looks like it! Wtf. That explains the strange behaviour. Will do a test and search and replace all the 1800 to something else :slight_smile:

I’ve tried to change the hard coded set_time_limit in the plugin and then everything worked. So i’m going to post a ticket at Updraft.

2 Likes

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.