简体   繁体   English

PHP忽略我的max_execution_time

[英]PHP Ignoring my max_execution_time

I have some task in my script that is about converting video with ffmpeg . 我的脚本中有一些关于使用ffmpeg转换视频的任务。 I do this with codeigniter 2.0.3 and locate the script at libraries and use shell_exec() to run ffmpeg. 我使用codeigniter 2.0.3执行此操作并在库中找到脚本并使用shell_exec()运行ffmpeg。

There are 3 tasks in my php script. 我的php脚本中有3个任务。

  1. Upload File 上传文件
  2. Convert video to .flv 将视频转换为.flv
  3. Generate thumb 生成拇指
  4. Save to db. 保存到数据库。

When I upload file, my php script start to convert my uploaded video. 当我上传文件时,我的php脚本开始转换我上传的视频。 But when converting is end about over 5 minutes. 但转换结束时间超过5分钟。 Its not continue to generate thumb. 它不会继续产生拇指。 And Its say 它说

PHP Fatal error: Maximum execution time of 300 seconds exceeded in C:\\AppServ\\www\\mis\\application\\libraries\\my_video_utility.php on line 102, referer: http://localhost/mis/test/ PHP致命错误:第102行的C:\\ AppServ \\ www \\ mis \\ application \\ libraries \\ my_video_utility.php超出了300秒的最大执行时间,参考: http:// localhost / mis / test /

I have set my max_execution time, max_input_time, etc to 3600 in php.ini also add set_time_limit() and set_ini() in my php script. 我已经在php.ini中将我的max_execution时间,max_input_time等设置为3600,并在我的php脚本中添加了set_time_limit()和set_ini()。 But, its still get error. 但是,它仍然会出错。

But, when I uploaded short video, its done. 但是,当我上传短视频时,它完成了。

Ok. 好。 I do this my self. 我自己这样做。 I have contacted my teacher. 我联系了我的老师。 There is a something that CodeIgniter not include this in their documentation. CodeIgniter有一些东西不包含在他们的文档中。

At line 103 in system/core/CodeIgniter.php 在system / core / CodeIgniter.php的第103行

if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
{
    @set_time_limit(300);
}

I try to change the value and it works. 我试着改变价值而且有效。

Solution to change set_time_limit() function in CodeIgniter.php is works, but I'm think it's not good idea to change framework's core files. 在CodeIgniter.php中更改set_time_limit()函数的解决方案是有效的,但我认为更改框架的核心文件并不是一个好主意。

I'm found another decision, you can call set_time_limit() where you need and it will be overlapp setting of time limit in CodeIgniter.php. 我找到了另一个决定,您可以在需要的地方调用set_time_limit() ,它将在CodeIgniter.php中重叠设置时间限制。

Codeigniter 2 has the set_time_limit function run with 300. After upgrading to Codeigniter 3, one thing started failing. Codeigniter 2的set_time_limit函数运行300.升级到Codeigniter 3后,有一件事开始失败。 After viewing this post, I realized that the set_time_limit call was removed in 3, so you may have to add the code in the accepted answer to your particular problem code. 在查看这篇文章之后,我意识到set_time_limit调用已在3中删除,因此您可能必须在您的特定问题代码的已接受答案中添加代码。 I would not recommend adding it back into the Codeigniter.php 我不建议将其添加回Codeigniter.php

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

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