WooCommerce PHP API 超时 70 秒,尽管 max_execution_time 600 秒
WooCommerce PHP API Timeout 70 seconds, Despite max_execution_time 600 seconds
我已经为 WooCommerce / Imagick 在通过 API 创建产品时超时而苦苦挣扎了几天。
每当我推送一批产品(即使是一小批)时,Imagick 缩略图生成过程在 70 秒后超时:
我的 phpinfo() 页面显示 max_execution_time 设置为 600 秒(我肯定在 plesk 中设置了)但是无论出于何种原因,Imagick / Thumbnail 进程似乎忽略了该超时。
我不知道 70 秒超时的来源以及如何控制它。
我试过:
- 在 .htaccess 中指定递归 php.ini - 无变化
- 在 .htaccess 中设置 php_value - This is no longer supported by Apache/Plesk
- 阅读源代码 - 我很快就迷失了方向,试图对此进行逆向工程 PHP
在这一点上,我们将不胜感激任何建议或帮助。谢谢!
额外上下文:
Wordpress 站点健康信息
### wp-core ###
version: 5.7
site_language: en_US
user_language: en_US
timezone: +10:00
permalink: /%postname%/
https_status: true
multisite: false
user_registration: 1
blog_public: 0
default_comment_status: open
environment_type: production
user_count: 2
dotorg_communication: true
### wp-paths-sizes ###
wordpress_path: /var/www/vhosts/REDACTED/httpdocs
wordpress_size: 46.52 MB (48782795 bytes)
uploads_path: /var/www/vhosts/REDACTED/httpdocs/wp-content/uploads
uploads_size: 733.78 MB (769420958 bytes)
themes_path: /var/www/vhosts/REDACTED/httpdocs/wp-content/themes
themes_size: 31.95 MB (33503279 bytes)
plugins_path: /var/www/vhosts/REDACTED/httpdocs/wp-content/plugins
plugins_size: 94.83 MB (99434224 bytes)
database_size: 242.02 MB (253771776 bytes)
total_size: 1.12 GB (1204913032 bytes)
### wp-dropins (2) ###
advanced-cache.php: true
maintenance.php: true
### wp-active-theme ###
name: Porto (porto)
version: 6.0.6
author: P-THEMES
author_website: http://www.portotheme.com/
parent_theme: none
theme_features: core-block-patterns, post-thumbnails, title-tag, editor-style, automatic-feed-links, woocommerce, menus, post-formats, html5, wp-block-styles, responsive-embeds, align-wide, editor-styles, editor-color-palette, widgets
theme_path: /var/www/vhosts/REDACTED/httpdocs/wp-content/themes/porto
auto_update: Enabled
### wp-mu-plugins (1) ###
BPS MU Tools: version: 6.0, author: AITpro
### wp-plugins-active (15) ###
Braintree for WooCommerce Payment Gateway: version: 2.4.3, author: WooCommerce, Auto-updates disabled
BulletProof Security: version: 4.7, author: AITpro Website Security, Auto-updates disabled
Classic Editor: version: 1.6, author: WordPress Contributors, Auto-updates disabled
Contact Form 7: version: 5.4, author: Takayuki Miyoshi, Auto-updates disabled
Media Deduper: version: 1.5.3, author: Cornershop Creative, Auto-updates disabled
Media Deduper Pro: version: 1.4.0, author: Cornershop Creative, Auto-updates disabled
Porto Theme - Functionality: version: 2.0.5, author: P-Themes, Auto-updates disabled
Tawk.to Live Chat: version: 0.5.2, author: Tawkto, Auto-updates disabled
WooCommerce: version: 5.1.0, author: Automattic, Auto-updates disabled
WooCommerce Menu Cart: version: 2.9.7, author: Jeremiah Prummer, Ewout Fernhout, Auto-updates disabled
WooCommerce Stripe Gateway: version: 4.9.0, author: WooCommerce, Auto-updates disabled
WooCommerce Table Rate Shipping: version: 3.0.30, author: WooCommerce, Auto-updates disabled
WP Mail SMTP: version: 2.6.0, author: WPForms, Auto-updates disabled
WP Super Cache: version: 1.7.2, author: Automattic, Auto-updates disabled
Yoast SEO: version: 15.9.2, author: Team Yoast, Auto-updates disabled
### wp-plugins-inactive (2) ###
Slider Revolution: version: 6.4.2, author: ThemePunch, Auto-updates disabled
WPBakery Page Builder: version: 6.6.0, author: Michael M - WPBakery.com, Auto-updates disabled
### wp-media ###
image_editor: WP_Image_Editor_Imagick
imagick_module_version: 1687
imagemagick_version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
file_uploads: File uploads is turned off
post_max_size: 64M
upload_max_filesize: 64M
max_effective_size: 64 MB
max_file_uploads: 20
imagick_limits:
imagick::RESOURCETYPE_AREA: 122 MB
imagick::RESOURCETYPE_DISK: 1073741824
imagick::RESOURCETYPE_FILE: 6144
imagick::RESOURCETYPE_MAP: 512 MB
imagick::RESOURCETYPE_MEMORY: 256 MB
imagick::RESOURCETYPE_THREAD: 6
gd_version: bundled (2.1.0 compatible)
ghostscript_version: 9.26
### wp-server ###
server_architecture: Linux 4.15.0-124-generic x86_64
httpd_software: Apache
php_version: 7.4.16 64bit
php_sapi: fpm-fcgi
max_input_variables: 2000
time_limit: 660
memory_limit: 512M
max_input_time: 600
upload_max_filesize: 64M
php_post_max_size: 64M
curl_version: 7.58.0 OpenSSL/1.1.1
suhosin: false
imagick_availability: true
pretty_permalinks: true
htaccess_extra_rules: true
### wp-database ###
extension: mysqli
server_version: 10.1.47-MariaDB-0ubuntu0.18.04.1
client_version: mysqlnd 7.4.16
### wp-constants ###
WP_HOME: undefined
WP_SITEURL: undefined
WP_CONTENT_DIR: /var/www/vhosts/REDACTED/httpdocs/wp-content
WP_PLUGIN_DIR: /var/www/vhosts/REDACTED/httpdocs/wp-content/plugins
WP_MEMORY_LIMIT: 256M
WP_MAX_MEMORY_LIMIT: 512M
WP_DEBUG: false
WP_DEBUG_DISPLAY: false
WP_DEBUG_LOG: false
SCRIPT_DEBUG: false
WP_CACHE: true
CONCATENATE_SCRIPTS: false
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_LOCAL_DEV: undefined
DB_CHARSET: utf8
DB_COLLATE: undefined
### wp-filesystem ###
wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable
mu-plugins: writable
### wp_mail_smtp ###
version: 2.6.0
license_key_type: lite
debug: No debug notices found.
db_tables: 3jJjCP_wpmailsmtp_tasks_meta
lite_install_date: Mar 16, 2021 @ 10:36am
历尽千辛万苦,我有了答案。
首先,我必须回答这个问题:PHP 脚本怎么会忽略我的 php.ini 文件和 .htaccess 文件中设置的时间限制?
回答:这个函数允许脚本设置它自己的行为并且基本上忽略 .ini 文件
https://www.php.net/manual/en/function.set-time-limit.php
下一个问题,这是在哪里调用的?
我在本机 WooCommerce Stripe 支付网关插件中找到了这个参考。即使我不使用该插件,它也会自动激活并以某种方式全局影响 WooCommerce /product/batch api
class-wc-stripe-connect-api.php 115/116 行
$http_timeout = 60; // 1 minute
wc_set_time_limit( $http_timeout + 10 );
我将 +10
更改为 +13
并确认异常在 73 秒后开始抛出。
我已经禁用了那个插件,神奇的是现在一切正常。没有更多的超时错误。
我已经为 WooCommerce / Imagick 在通过 API 创建产品时超时而苦苦挣扎了几天。
每当我推送一批产品(即使是一小批)时,Imagick 缩略图生成过程在 70 秒后超时:
我的 phpinfo() 页面显示 max_execution_time 设置为 600 秒(我肯定在 plesk 中设置了)但是无论出于何种原因,Imagick / Thumbnail 进程似乎忽略了该超时。
我不知道 70 秒超时的来源以及如何控制它。
我试过:
- 在 .htaccess 中指定递归 php.ini - 无变化
- 在 .htaccess 中设置 php_value - This is no longer supported by Apache/Plesk
- 阅读源代码 - 我很快就迷失了方向,试图对此进行逆向工程 PHP
在这一点上,我们将不胜感激任何建议或帮助。谢谢!
额外上下文:
Wordpress 站点健康信息
### wp-core ###
version: 5.7
site_language: en_US
user_language: en_US
timezone: +10:00
permalink: /%postname%/
https_status: true
multisite: false
user_registration: 1
blog_public: 0
default_comment_status: open
environment_type: production
user_count: 2
dotorg_communication: true
### wp-paths-sizes ###
wordpress_path: /var/www/vhosts/REDACTED/httpdocs
wordpress_size: 46.52 MB (48782795 bytes)
uploads_path: /var/www/vhosts/REDACTED/httpdocs/wp-content/uploads
uploads_size: 733.78 MB (769420958 bytes)
themes_path: /var/www/vhosts/REDACTED/httpdocs/wp-content/themes
themes_size: 31.95 MB (33503279 bytes)
plugins_path: /var/www/vhosts/REDACTED/httpdocs/wp-content/plugins
plugins_size: 94.83 MB (99434224 bytes)
database_size: 242.02 MB (253771776 bytes)
total_size: 1.12 GB (1204913032 bytes)
### wp-dropins (2) ###
advanced-cache.php: true
maintenance.php: true
### wp-active-theme ###
name: Porto (porto)
version: 6.0.6
author: P-THEMES
author_website: http://www.portotheme.com/
parent_theme: none
theme_features: core-block-patterns, post-thumbnails, title-tag, editor-style, automatic-feed-links, woocommerce, menus, post-formats, html5, wp-block-styles, responsive-embeds, align-wide, editor-styles, editor-color-palette, widgets
theme_path: /var/www/vhosts/REDACTED/httpdocs/wp-content/themes/porto
auto_update: Enabled
### wp-mu-plugins (1) ###
BPS MU Tools: version: 6.0, author: AITpro
### wp-plugins-active (15) ###
Braintree for WooCommerce Payment Gateway: version: 2.4.3, author: WooCommerce, Auto-updates disabled
BulletProof Security: version: 4.7, author: AITpro Website Security, Auto-updates disabled
Classic Editor: version: 1.6, author: WordPress Contributors, Auto-updates disabled
Contact Form 7: version: 5.4, author: Takayuki Miyoshi, Auto-updates disabled
Media Deduper: version: 1.5.3, author: Cornershop Creative, Auto-updates disabled
Media Deduper Pro: version: 1.4.0, author: Cornershop Creative, Auto-updates disabled
Porto Theme - Functionality: version: 2.0.5, author: P-Themes, Auto-updates disabled
Tawk.to Live Chat: version: 0.5.2, author: Tawkto, Auto-updates disabled
WooCommerce: version: 5.1.0, author: Automattic, Auto-updates disabled
WooCommerce Menu Cart: version: 2.9.7, author: Jeremiah Prummer, Ewout Fernhout, Auto-updates disabled
WooCommerce Stripe Gateway: version: 4.9.0, author: WooCommerce, Auto-updates disabled
WooCommerce Table Rate Shipping: version: 3.0.30, author: WooCommerce, Auto-updates disabled
WP Mail SMTP: version: 2.6.0, author: WPForms, Auto-updates disabled
WP Super Cache: version: 1.7.2, author: Automattic, Auto-updates disabled
Yoast SEO: version: 15.9.2, author: Team Yoast, Auto-updates disabled
### wp-plugins-inactive (2) ###
Slider Revolution: version: 6.4.2, author: ThemePunch, Auto-updates disabled
WPBakery Page Builder: version: 6.6.0, author: Michael M - WPBakery.com, Auto-updates disabled
### wp-media ###
image_editor: WP_Image_Editor_Imagick
imagick_module_version: 1687
imagemagick_version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org
file_uploads: File uploads is turned off
post_max_size: 64M
upload_max_filesize: 64M
max_effective_size: 64 MB
max_file_uploads: 20
imagick_limits:
imagick::RESOURCETYPE_AREA: 122 MB
imagick::RESOURCETYPE_DISK: 1073741824
imagick::RESOURCETYPE_FILE: 6144
imagick::RESOURCETYPE_MAP: 512 MB
imagick::RESOURCETYPE_MEMORY: 256 MB
imagick::RESOURCETYPE_THREAD: 6
gd_version: bundled (2.1.0 compatible)
ghostscript_version: 9.26
### wp-server ###
server_architecture: Linux 4.15.0-124-generic x86_64
httpd_software: Apache
php_version: 7.4.16 64bit
php_sapi: fpm-fcgi
max_input_variables: 2000
time_limit: 660
memory_limit: 512M
max_input_time: 600
upload_max_filesize: 64M
php_post_max_size: 64M
curl_version: 7.58.0 OpenSSL/1.1.1
suhosin: false
imagick_availability: true
pretty_permalinks: true
htaccess_extra_rules: true
### wp-database ###
extension: mysqli
server_version: 10.1.47-MariaDB-0ubuntu0.18.04.1
client_version: mysqlnd 7.4.16
### wp-constants ###
WP_HOME: undefined
WP_SITEURL: undefined
WP_CONTENT_DIR: /var/www/vhosts/REDACTED/httpdocs/wp-content
WP_PLUGIN_DIR: /var/www/vhosts/REDACTED/httpdocs/wp-content/plugins
WP_MEMORY_LIMIT: 256M
WP_MAX_MEMORY_LIMIT: 512M
WP_DEBUG: false
WP_DEBUG_DISPLAY: false
WP_DEBUG_LOG: false
SCRIPT_DEBUG: false
WP_CACHE: true
CONCATENATE_SCRIPTS: false
COMPRESS_SCRIPTS: undefined
COMPRESS_CSS: undefined
WP_LOCAL_DEV: undefined
DB_CHARSET: utf8
DB_COLLATE: undefined
### wp-filesystem ###
wordpress: writable
wp-content: writable
uploads: writable
plugins: writable
themes: writable
mu-plugins: writable
### wp_mail_smtp ###
version: 2.6.0
license_key_type: lite
debug: No debug notices found.
db_tables: 3jJjCP_wpmailsmtp_tasks_meta
lite_install_date: Mar 16, 2021 @ 10:36am
历尽千辛万苦,我有了答案。
首先,我必须回答这个问题:PHP 脚本怎么会忽略我的 php.ini 文件和 .htaccess 文件中设置的时间限制?
回答:这个函数允许脚本设置它自己的行为并且基本上忽略 .ini 文件 https://www.php.net/manual/en/function.set-time-limit.php
下一个问题,这是在哪里调用的? 我在本机 WooCommerce Stripe 支付网关插件中找到了这个参考。即使我不使用该插件,它也会自动激活并以某种方式全局影响 WooCommerce /product/batch api
class-wc-stripe-connect-api.php 115/116 行
$http_timeout = 60; // 1 minute
wc_set_time_limit( $http_timeout + 10 );
我将 +10
更改为 +13
并确认异常在 73 秒后开始抛出。
我已经禁用了那个插件,神奇的是现在一切正常。没有更多的超时错误。