今天 ,WooCommerce尝试切换到PHP8.0的时候,网站会出错,错误提示如下:
Fatal error: Uncaught Error: Call to undefined function putenv() in /www/wwwroot/shop2.jiea.cc/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php:37 Stack trace: #0 /www/wwwroot/shop2.jiea.cc/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php(49): WC_Regenerate_Images_Request->__construct() #1 /www/wwwroot/shop2.jiea.cc/wp-includes/class-wp-hook.php(308): WC_Regenerate_Images::init() #2 /www/wwwroot/shop2.jiea.cc/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters() #3 /www/wwwroot/shop2.jiea.cc/wp-includes/plugin.php(517): WP_Hook->do_action() #4 /www/wwwroot/shop2.jiea.cc/wp-settings.php(617): do_action() #5 /www/wwwroot/shop2.jiea.cc/wp-config.php(96): require_once('...') #6 /www/wwwroot/shop2.jiea.cc/wp-load.php(50): require_once('...') #7 /www/wwwroot/shop2.jiea.cc/wp-blog-header.php(13): require_once('...') #8 /www/wwwroot/shop2.jiea.cc/index.php(17): require('...') #9 {main} thrown in /www/wwwroot/shop2.jiea.cc/wp-content/plugins/woocommerce/includes/class-wc-regenerate-images-request.php on line 37 此站点遇到了致命错误。
然后我就在谷歌尝试搜索该问题解决方案,终于在一个网页中找到了解决方案:
关于该错误问题的讨论页面:https://github.com/woocommerce/woocommerce/issues/31942
在该页面中,我看到了这么一句话:
+1 had the same issue and fixed it over the workaround.
Though had then some issues with WooCommerce Blocks why i reverted to php 7.4 for now.
Hoster seems to have deactivated putenv()
然后,我就意识到了可能是PHP8.0 putenv()这个函数的问题
于是,我切换到宝塔后台——软件商店——PHP8.0——设置——禁用函数里面,删除putenv这个函数
删除后,我返回网站,发现网站果然恢复正常了,至此,问题完美解决。