致命错误:在joomla解决方案中,最长执行时间超过了30秒,而没有更改ini文件 [英] Fatal error: Maximum execution time of 30 seconds exceeded in joomla solution without changing ini file

查看:50
本文介绍了致命错误:在joomla解决方案中,最长执行时间超过了30秒,而没有更改ini文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Joomla扩展,其中将表A中的记录存储到表B中.如果表A中包含的数据较少,我的脚本可以正常工作. 如果表A包含大量数据.在插入时,巨大的数据执行量已超过&显示此错误'致命错误:超过30秒的最大执行时间 /mysite/libraries/joomla/database/database/mysqli.php,行382'. 我可以通过在ini文件中进行更改来解决此问题,但是人们会在其站点中使用它的Joomla扩展名,因此我实际上并不想告诉他们在ini文件中进行更改.

I'm created a Joomla extension in which i'm storing records from table A to table B. My script is working fine if table A contains less data. If table A contains large amout of data. While inserting this huge data execution is getting exceed & showing this error 'Fatal error: Maximum execution time of 30 seconds exceeded in /mysite/libraries/joomla/database/database/mysqli.php on line 382'. I can overcome this problem by making change in ini file, but its Joomla extension which people gonna use it in their site so i can't tell them to make change in ini file infact i don't wanna tell them.

推荐答案

从技术上讲,您可以使用

Technically, you can increase the maximum execution time using set_time_limit. Personally, I wouldn't mess with limits other people set on their servers, assuming they put them in for a reason (performance, security - especially in a shared hosting context, where software like Joomla! is often found). Also, set_time_limit won't work if PHP is run in safe mode.

剩下的就是将任务分成多个步骤.例如,如果您的表有100000条记录,并且您测量到可以在合理的时间内处理大约5000条记录,则分20个步骤进行操作.

So what you're left with is splitting the task into multiple steps. For example, if your table has 100000 records and you measure that you can process about 5000 records in a reasonable amount of time, then do the operation in 20 individual steps.

在一般系统上,每个步骤的执行时间应该少于30秒.请注意,步骤数是动态的,您可以通过编程方式将记录数除以一个常数(在测试过程中找出有用的值),以获取运行时的步骤数.

Execution time for each step should be a good deal less than 30 seconds on an average system. Note that the number of steps is dynamic, you programmatically divide the number of records by a constant (figure out a useful value during testing) to get the number of steps during runtime.

您需要将脚本分为两个部分,一个部分找出所需的步骤数,将其显示给用户,然后通过向第二个脚本发送AJAX请求来依次运行一个步骤(例如:过程记录" 5001到10000),并在适当的服务器响应到达(即请求完成)后将步骤标记为已完成(供用户查看).

You need to split your script into two parts, one that finds out the number of steps required, displays them to the user and sequentially runs one step after another, by sending AJAX requests to the second script (like: "process records 5001 to 10000"), and marking steps as done (for the user to see) when the appropriate server respone arrives (i.e. request complete).

第二部分完全是服务器端的,并且接受AJAX请求.该脚本在服务器上完成实际工作.它必须接收某种类型的参数(处理记录5001到10000"请求)以了解它应该处理的步骤.完成步骤后,它会向客户端脚本返回成功"(或可能是失败")代码,以便它可以通知用户.

The second part is entirely server-sided and accepts AJAX requests. This script does the actual work on the server. It must receive some kind of parameters (the "process records 5001 to 10000" request) to understand which step it's supposed to process. When it's done with its step, it returns a "success" (or possibly "failure") code to the client script, so that it can notify the user.

此主题有多种变化,例如,您可以构建一个脚本,该脚本将用户重定向到自身,但使用不同的参数,因此它可以知道它从何处中断,并可以从那里继续进行下一步.通常,您需要一种能够为用户提供尽可能多的信息和控制权的解决方案.

There are variations on this theme, for instance you can build a script which redirects the user to itself, but with different parameters, so it's aware where it left off and can pick up from there with the next step. In general, you'd want the solution that gives the user the most information and control possible.

这篇关于致命错误:在joomla解决方案中,最长执行时间超过了30秒,而没有更改ini文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆