Set_time_limit() function is currently disabled

Issue Summary

On trying to use a plugin to transfer the DB of a local site to a remote host, I get the following error:

PHP Function Disabled — The set_time_limit() function is currently disabled on your server. We use this function to ensure that the migration doesn’t time out. We haven’t disabled the plugin however, so you’re free to cross your fingers and hope for the best. You may want to contact your web host to enable this function.Your current PHP run time limit is set to 1200 seconds.

Troubleshooting Questions

  • Does this happen for all sites in Local, or just one in particular?
    Have not seen this error before, I am doing this all the time.

  • Are you able to create a new, plain WordPress site in Local and access it in a Browser?

Yes, all works fine.

I looked into the php.ini.hbs file and ith shows this:

; Maxes
max_execution_time = 1200
max_input_time = 600
max_input_vars = 5000
memory_limit = 1024M
post_max_size = 256M
max_file_uploads = 20
output_buffering = 4096

Replication

Describe the steps that others can take to replicate this issue. If you have screenshots that can help clarify what is happening, please include them!

System Details

  • Which version of Local is being used?
    Latest version

  • What Operating System (OS) and OS version is being used?
    macOS Mojave webserver is NGINX
    php version is 8.0

  • Attach the Local Log. See this Community Forum post for instructions on how to do so:
    log shows no recent errors:

2021/11/09 13:55:09 [error] 3533#0: *306 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: “POST /wp-admin/admin-ajax.php HTTP/1.0”, upstream: “fastcgi://unix:/Users/eagerbob/Library/Application Support/Local/run/WnvIwmkB4/php/php-fpm.socket:”, host: “virto.local”, referrer: “http://virto.local/wp-admin/admin.php?page=system-info
2021/11/09 15:08:20 [error] 3717#0: *3727 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: , request: “POST /wp-admin/admin-ajax.php HTTP/1.0”, upstream: “fastcgi://unix:/Users/eagerbob/Library/Application Support/Local/run/WnvIwmkB4/php/php-fpm.socket:”, host: “virto.local”, referrer: “http://virto.local/wp-admin/admin.php?page=etruscan_core_menu

//EDIT

If I switch back to an older, pre 8.0 PHP version,. the problem goes away and it works as expected. However, I would like to use the latest PHP version so what can we change in the settings so that it works again?
Thanks

I tried replicating this on a brand new PHP 8.0 site in Local and I’m not able to get the PHP function Disabled error.

As a test, I created a new file within the root of the Local site and added this code:

<?php

set_time_limit(1);

/**
 * Can't use sleep() because that's not included in the calculation of
 * "active script" when PHP calculates the set_time_limit() function.
 * Instead, we do something that takes a few seconds to complete, like
 * try and get a page on a remote site.
 */
// sleep(5);

$example = 0;
for ($i = 0; $i < 10; ++$i) {
    $example = ($i % 2 == 0) ? file_get_contents("https://example.com") : false;
}
var_dump($example);

Basically, that sets the time limit to 1 second, and then tries to get the contents of a remote site.

When I access that file in a browser, I don’t get a “function disabled” error, instead, I get the error about the script taking to long (ie, what the set_time_limit() function is supposed to do.)

Where exactly are you seeing that PHP Function Disabled error? Is that within the WordPress admin of the Local site, or somewhere else?

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