Victor Aurélio
Victor Aurélio

Reputation: 2555

requiring a dir instead of a file?

I got this php error message:

Warning: require(/home/victor/public_html/plugindev/wp-includes/plugin.php): failed to open stream: Not a directory in /home/victor/public_html/plugindev/wp-settings.php on line 75

Fatal error: require(): Failed opening required '/home/victor/public_html/plugindev/wp-includes/plugin.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/victor/public_html/plugindev/wp-settings.php on line 75

but...:

 ~  stat /home/victor/public_html/plugindev/wp-includes/plugin.php 
File: ‘/home/victor/public_html/plugindev/wp-includes/plugin.php’
➜  ~  stat /home/victor/public_html/plugindev/wp-settings.php
File: ‘/home/victor/public_html/plugindev/wp-settings.php’

and the most strange part, the occurs randomly and at randomly files and all exists. (ie already seen the same error for other files)

I think is is a incompatiblity with plugin I'm developing but doesn't know how to debug

Upvotes: 0

Views: 47

Answers (1)

Ne Ma
Ne Ma

Reputation: 1709

There is clearly a permissions problem here.

<?php
$dir = '/path/to/dir';
$file = $dir . '/file.ext';

echo is_readable($dir)
    ? "Dir is readable"
    : "Dir is not readable";

echo is_readable($file)
    ? "File is readable"
    : "File is not readable";

That snippet of code will tell you if there is a permissions issue and you can resolve the code appropriately. If it is 'random' then its possible that you are expecting files to be present when they have not been generated yet? If that is the case, the checking code above can be used to dictate if a file needs to be created.

Upvotes: 1

Related Questions