L
L
ligisayan2018-11-11 19:11:08
local server
ligisayan, 2018-11-11 19:11:08

Error in the wordpress admin "failed to open stream: No such file or directory" - how to fix?

Hello! I have a wordpress site with the WP Hide Post plugin installed . There is a need to transfer the site to a new hosting, but I decided to play it safe and check its performance after importing it to a local Open Server .
And not in vain - at the top of the admin panel I get the following errors:

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

Pointed to by the following lines of code in 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 );
...
}

How can you fix them? If I deactivate the plugin, the error disappears. How can I fix errors in an included plugin?
Or is this a bug only because of the local server? Cleared the cache.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pychev Anatoly, 2018-11-11
@pton

Well, the first error says that the file on such and such a path was not found.
Do you have any questions about the path to the file? Calls me.
I would insert something before the fopen function to see the contents of the $file variable.
For example
This will create a log.log file in the folder with the file and output the contents of this variable there.
Well, you have to look further.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question