gpt4 book ai didi

脚本第一行超出 PHP 最长执行时间

转载 作者:搜寻专家 更新时间:2023-10-31 22:01:09 26 4
gpt4 key购买 nike

我在 PHP 自己的错误日志中遇到间歇性错误,如下所示:

09-Mar-2015 09:18:12 Europe/Dublin] PHP Fatal error: Maximum execution time of 120 seconds exceeded in C:\inetpub\site\www\index.php on line 27

该应用程序在 CakePHP 上运行,因此 index.php 只是 Cake 的常规请求处理程序。对应用程序的每个请求都通过此文件。

该站点在 Windows/IIS 中的 PHP 5.4 上运行。 IIS 自己的此特定请求日志显示这是一个 POST 请求。

这是 index.php。第 27 行是注释后实际代码的第一行,因此可以安全地假设它是 PHP 尝试根据请求执行的第一行。

<?php
/**
* Requests collector.
*
* This file collects requests if:
* - no mod_rewrite is available or .htaccess files are not supported
* - requires App.baseUrl to be uncommented in app/Config/core.php
* - app/webroot is not set as a document root.
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

/**
* Get Cake's root directory
*/
define('APP_DIR', 'app');
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__));
define('WEBROOT_DIR', 'webroot');
define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);

/**
* This only needs to be changed if the "cake" directory is located
* outside of the distributed structure.
* Full path to the directory containing "cake". Do not add trailing directory separator
*/
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
}

require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';

这里有两个问题。

首先,到底是什么导致了这个问题?一些我没有想到的 IIS 或 PHP 设置?我无法在开发中重现它。

其次,遇到此错误的用户只会看到白屏死机,因为 CakePHP 框架尚未启动并注册关闭函数或错误处理程序。任何关于我如何至少用优雅的“出了点问题,请重试”来处理这个问题的临时想法都会很有用。您不能在 index.php 中使用 register_shutdown_function(),因为它会覆盖 CakePHP 的错误处理程序。

最佳答案

问题原来是 max_input_time 设置的值太低了。只有连接速度慢且上传大文件的用户才会遇到此问题。我在 php.ini 中增加了 max_input_time,问题消失了。

关于脚本第一行超出 PHP 最长执行时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28939761/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com