@ligisayan

Ошибка в админке wordpress «failed to open stream: No such file or directory» — как исправить?

Всем привет! Есть сайт на wordpress с установленным плагином WP Hide Post. Есть необходимость переноса сайта на новый хостинг, но решил перестраховаться и проверить его работоспособность после импорта на локальный Open Server.
И не зря - вверху админпанели получаю следующие ошибки:

fopen(C:\OSPanel\domains\localhost\site/wp-content/plugins/C:\OSPanel\domains\localhost\site\wp-content\plugins\wp-hide-post\wp-hide-post.php): failed to open stream: No such file or directory in
in C:\OSPanel\domains\localhost\site\wp-includes\functions.php on line 4848

Warning: fread() expects parameter 1 to be resource, boolean given in C:\OSPanel\domains\localhost\site\wp-includes\functions.php on line 4851

Warning: fclose() expects parameter 1 to be resource, boolean given in C:\OSPanel\domains\localhost\site\wp-includes\functions.php on line 4854


На которые указывает следующие строки кода в functions.php
/**
 * Retrieve metadata from a file.
 *
 * Searches for metadata in the first 8kiB of a file, such as a plugin or theme.
 * Each piece of metadata must be on its own line. Fields can not span multiple
 * lines, the value will get cut at the end of the first line.
 *
 * If the file data is not within that first 8kiB, then the author should correct
 * their plugin file and move the data headers to the top.
 *
 * @link https://codex.wordpress.org/File_Header
 *
 * @since 2.9.0
 *
 * @param string $file            Path to the file.
 * @param array  $default_headers List of headers, in the format array('HeaderKey' => 'Header Name').
 * @param string $context         Optional. If specified adds filter hook {@see 'extra_$context_headers'}.
 *                                Default empty.
 * @return array Array of file headers in `HeaderKey => Header Value` format.
 */
function get_file_data( $file, $default_headers, $context = '' ) {
	// We don't need to write to the file, so just open for reading.
	$fp = fopen( $file, 'r' );

	// Pull only the first 8kiB of the file in.
	$file_data = fread( $fp, 8192 );

	// PHP will close file handle, but we are good citizens.
	fclose( $fp );

	// Make sure we catch CR-only line endings.
	$file_data = str_replace( "\r", "\n", $file_data );
...
}


Как можно их исправить? Если плагин деактивирую - ошибка исчезает. Как можно исправить ошибки в включенным плагином?

Или это ошибка только из-за локального сервера? Кеш очищал.
  • Вопрос задан
  • 2114 просмотров
Пригласить эксперта
Ответы на вопрос 1
Ну первая ошибка говорит, что файл по такому-то пути не найден.
У Вас путь к файлу не вызывает вопросов? У меня вызывает.

я бы вставил перед функцией fopen что то что бы увидеть содержимое переменной $file
Например
error_log('$file: ' . print_r($file, true) . PHP_EOL , 3, __DIR__ . '/log.log');

Это создаст в папке с файлом фал log.log и выведет туда содержимое этой переменной.
Ну а дальше надо смотреть.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы