WordPress出现ftp_fget() expects parameter 1 to be resource, null given in错误

为糖祖的网站购买了Astra Pro+Element Pro,我在宝塔里将站点和数据库分别备份,然后开始乱搞。等到我觉得乱搞到差不多的时候,我开始删页面,删库,然后恢复。

谁知道恢复完后,无论是wordpress 的前台还是后台均出现了错误提示:

“ftp_fget() expects parameter 1 to be resource, null given in XXXXXwp-admin/includes/class-wp-filesystem-ftpext.php  on line 146

我心想奇怪了,为什么会这样,莫非是PHP版本的问题?现在是PHP74,很多PHP5X时代的语法它是不支持的,于是,我又开始瞎折腾,宝塔安装了PHP72和PHP56,分别切换过去,问题依旧。

最后直接百度了“ftp_fget() expects parameter 1 to be resource, null given i”,在一片类似的文章中找到解决方法——

fread() expects parameter 1 to be resource 原因与解决方法
https://www.fujieace.com/php/fopen-fread-fclose.html

宝塔打开class-wp-filesystem-ftpext.php,翻到146行,从146-150行代码如下:

if ( ! ftp_fget( $this->link, $temphandle, $file, FTP_BINARY ) ) {
fclose( $temphandle );
unlink( $tempfile );
return false;
}

在ftp_fget之前加@号,错误消失。

随便看看

Irritative travel,Crazy travel
一路向北——06年7月游 与X商量以后...
阅读全文 >>>
“碳”是掀翻欧美霸权的核心利器
为何中国要如此重手地抓「能耗双控...
阅读全文 >>>
谈谈中国足球,写写李铁。
之前,我出于对中国国家男子足球队...
阅读全文 >>>
推荐阅读  最好用的 V2Ray 一键安装脚本 & 管理脚本