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之前加@号,错误消失。

随便看看

过完春节回顺德
已回顺德,存糖渐清,因一则今年不...
阅读全文 >>>
I have to lose weight !
博客“平凡的世界”里一篇关于减肥...
阅读全文 >>>
Talk with George@Ethernetservers
Hello, It seens my IP has been blocked by the GFW...
阅读全文 >>>
推荐阅读  整顿博客