繁体   English   中英

尽管正确设置了php.ini,但“最大执行时间”错误

[英]Max Execution Time error despite setting php.ini correctly

过去一个小时,我一直在为此苦苦挣扎。 我在Windows机上使用WAMP Local服务器,所以一切都在我的控制之下。 尝试导入Wordpress xml文件时出现最大执行时间60秒错误。

我已经在php.ini:设置了这些值php.ini:

max_execution_time = 1200
memory_limit = 512M
max_input_time = -1

I have also edited my wp-config file : set_time_limit(0);

进行更改后,我重新启动了服务器。 还是我出错

) Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\xxa\wp-includes\wp-db.php on line 1285

谢谢阿马尔

这必须与硬编码的max_execution_time设置为60有关。

我在WordPress导入程序中遇到了同样的问题。 原来是由于wp-includes/functions.php文件中的硬编码@set_time_limit( 60 )

function wp_get_http( $url, $file_path = false, $red = 1 ) { @set_time_limit( 60 );

我注释掉了set_time_limit( 60 )调用,此后它运行良好:

//@set_time_limit( 60 );

当插件执行的初始检查时间超过30秒时,可能会出现此问题。

请尝试:

  1. 修改wp-config.php:set_time_limit(60);

重要提示–如果要在wp-config.php中进行更改,请在“ / *”上方添加此行,那就停止编辑! 快乐的博客。 * /”评论。

  1. 修改WordPress安装的/.htaccess文件php_value max_execution_time 60

  2. 修改php.ini文件max_execution_time = 60;

最好在wp-config.php文件中进行更改。

请让我知道是否可以解决问题。

谢谢

我必须自己测试register_shutdown_function()-我认为它不会运行。 毕竟,一旦没有更多的内存或执行时间过去了,用户功能如何运行? 我很惊讶地发现关机功能确实可以运行,即使在OOM情况下,或者在执行时间已超过时,我也感到惊讶。 概念验证:要测试内存限制:

<?php
function asdf() { echo "omg\n"; }
register_shutdown_function('asdf');

ini_set('memory_limit', '1000');

$x = '';
while(true) {
 $x .= 'lkajsdlfkjasldkfjlaskdfjasldkfj';
}

输出:

PHP Fatal error:  Allowed memory size of 262144 bytes exhausted (tried to allocate 169540 bytes) in /home/scratch.php on line 9
PHP Stack trace:
PHP   1. {main}() /home/scratch.php:0

Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 169540 bytes) in /home/scratch.php on line 9

Call Stack:
    0.0002      81360   1. {main}() /home/scratch.php:0

omg

要测试执行时间:

cat scratch.php
<?php
function asdf() { echo "omg\n"; }
register_shutdown_function('asdf');

set_time_limit(1);

while(true) {}

输出:

PHP Fatal error:  Maximum execution time of 1 second exceeded in /home/scratch.php on line 7
PHP Stack trace:
PHP   1. {main}() /home/scratch.php:0

Fatal error: Maximum execution time of 1 second exceeded in /home/scratch.php on line 7

Call Stack:
    0.0002      80200   1. {main}() /home/scratch.php:0

omg

请注意,要使您的消息在PHP的错误输出之前显示,您必须完全禁用PHP的错误输出。 无论如何,这是生产现场的最佳实践。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM