[英]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秒時,可能會出現此問題。
請嘗試:
重要提示–如果要在wp-config.php中進行更改,請在“ / *”上方添加此行,那就停止編輯! 快樂的博客。 * /”評論。
修改WordPress安裝的/.htaccess文件php_value max_execution_time 60
修改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.