Wordpress 导入器错误:最大执行时间 60 秒 [英] Wordpress importer error: max execution time 60 seconds

查看:50
本文介绍了Wordpress 导入器错误:最大执行时间 60 秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试导入 Wordpress 主题 单元测试xml 与默认 wordpress importer 插件.我收到以下错误:

I am trying to import a Wordpress theme unit test xml with default wordpress importer plugin. I get following error:

致命错误:E:\XAMPP\htdocs\wp\wp-includes\wp-db.php 中超过了最大执行时间 60 秒

Fatal error: Maximum execution time of 60 seconds exceeded in E:\XAMPP\htdocs\wp\wp-includes\wp-db.php

这是一个基本的 Wordpress 4.5.1 安装,没有额外的插件或主题,除了 wordpress importer v 0.6.1,在我的本地 XAMPP 服务器上,执行时间限制在 php.ini 中设置为 6000,我可以看到这个预设在 xampp 的 php_info 中.我已经尝试在 wp-config.php 和 wp-db.php 中添加 set_time_limit(6000) ,结果是同样丑陋的错误.

This is a basic Wordpress 4.5.1 installation with no additional plugins or themes, except wordpress importer v 0.6.1, on my local XAMPP server, execution time limit is set to 6000 in php.ini and I can see this preset in xampp's php_info. I've already tried adding set_time_limit(6000) in wp-config.php and wp-db.php with the same ugly error as result.

任何想法为什么会发生这种情况以及如何提供帮助?

Any ideas why is this happening and how can it be helped?

推荐答案

我找到了发生此错误的确切原因,因此我将尝试为我自己的问题提供答案.

I found the precise reason why this error happens, so I'll try to provide the answer to my own question.

wp-includes/deprecated.php 中有一个名为 wp_get_http 的函数,wordpress 导入器插件(在 wordpress-importer.php 源文件中)仍在使用该函数.在此函数内部调用 set_time_limit(60),它是所有 wordpress 源代码中对该函数的两次调用之一,参数为 60,因此这是将导入程序执行时间限制为 60 秒的地方.

There is a function called wp_get_http in wp-includes/deprecated.php, which is still used by the wordpress importer plugin (inside wordpress-importer.php source file). Inside this function set_time_limit(60) is called, it is the one of exactly two calls to this function with parameter 60 in all the wordpress source code, so this is the place that limits importer execution time to 60 seconds.

wp_get_http 在执行流程的后期被导入插件调用,因此它会覆盖 wp-config.php 中任何其他可能的 set_time_limit() 调用,并且无法通过 php.ini 中的修改来纠正,这可能会发生托管服务提供商不允许.

wp_get_http is called by importer plugin rather late in the execution flow, so it overrides any other possible set_time_limit() calls in wp-config.php, and cannot be corrected by modifications in php.ini, which on their own may happen to be not allowed by hosting provider.

对我有用的快速解决方案是修改 wp-includes/deprecated.php 中 wp_get_http() 中的 set_time_limit 调用,如下所示:

The quick solution to this, which worked for me, is to modify the set_time_limit call inside wp_get_http() in wp-includes/deprecated.php, like this:

set_time_limit(1200); // Limit to 20 minutes

它让 wordpress 导入器有 20 分钟的时间来获取在导入过程中可能需要的所有远程文件.可能这不是最安全的解决方案,但它对我有用.

It gives the wordpress importer 20 minutes to fetch all the remote files it may require during import. May be this is not the safest solution, but it worked for me.

这篇关于Wordpress 导入器错误:最大执行时间 60 秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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