WordPress - PHP 警告无法打开流:没有这样的文件或目录(高级-cache.php)

WordPress - PHP Warning failed to open stream: No such file or directory (advanced-cache.php)

我在后端和前端页面 (WordPress) 上收到此 PHP 警告,但不知道如何解决:

Warning: include(/home/.../public_html/wp-content/advanced-cache.php): failed to open stream: No such file or directory in /home/.../public_html/wp-settings.php on line 84

Warning: include(): Failed opening '/home/.../public_html/wp-content/advanced-cache.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/.../public_html/wp-settings.php on line 84

确实,该目录中没有高级-cache.php(不确定是否曾经有过),但完全相同的配置在不同的服务器上运行时没有警告。

将不胜感激任何帮助。谢谢

我认为您已经安装了 Advance cache plugin,并且设置了 WP_CACHE

define('WP_CACHE', true);
// or may be it is a file like, if so then comment this line,
// below is the statement which need to be commented
// define('WP_CACHE', is_file(__DIR__.'/wp-content/advanced-cache.php'));

为防止出现此错误,您可以设置为 false,例如

define('WP_CACHE', false);

../wp-content/advanced-cache.php 是在安装任何缓存插件时动态生成的,尤其是来自 wordpress.org 的缓存插件使用它。所以你将无法在全新的 WP 安装中找到该文件。

请参考link

在你的情况下,我假设你已经安装了一些缓存插件,并且由于任何原因 advanced-cache.php 文件从文件夹中删除或者执行文件可能存在权限问题。这就是为什么当您的缓存插件尝试搜索并包含 advanced-cache.php 文件时却无法找到或执行它,这会引发您提到的错误。

为了进一步的可能性和建议,我需要知道你使用哪个缓存插件。如果您希望我进一步提供帮助,请告诉我...

除了在 wp-config 文件中将 WP-CACHE 设置为 false 之外,您可能还需要重命名或删除 wp-contet/advanced-cache.php 文件。

转到 wp-config.php 文件

并检查这一行

define('WP_CACHE', true); 

如果你找到了就改成

define('WP_CACHE', false); 

大功告成。谢谢

执行以下操作帮助我恢复了我的画廊和 wp-admin 访问权限:

转到 wp-content 文件夹(获得对网站的 FTP 访问权限)

检查高级-cache.php 和对象-cache.php 文件是否存在。

将文件重命名为 .bak,如下所示: 高级-cache.php.bak 和对象-cache.php.bak

此错误是由于我的 W3 Total Cache 插件的缓存功能所致。 希望这对我有所帮助。