• I get the following warning about a hundred times down the page every time I run a theme check:

    Warning: file_get_contents(D:\www\webroot\work\wordpress.dev/wp-content/themes/theme\.git): failed to open stream: Permission denied in D:\www\webroot\work\wordpress.dev\wp-content\plugins\theme-check\main.php on line 29

    I understand this to be file permissions that Windows has set on the .git directories. I was just wondering if you would add a simple fix to the main.php file?

    I propose the following change on line 29 of main.php:

    $other[$filename] = @file_get_contents( $filename );

    instead of:

    $other[$filename] = file_get_contents( $filename );

    to suppress the warnings. Of course that is a simple fix, feel free to do your own proper exception checking with a try/catch routine.

    Would make me super happy to not have to see these warnings again 🙂

    Thanks.

    http://wordpress.org/extend/plugins/theme-check/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Simon Prosser

    (@pross)

    Suppressing errors with @ goes against everything the plugin is designed to do 😉

    Thread Starter David Hancock

    (@davgothic)

    Yeah I understand that, I felt dirty just typing it lol. It’s just when you get a page like this.

    It starts getting a little annoying having to scroll a bajillion lines to get to the good stuff. I use git in my workflow it’d be nice if it didn’t throw up all over the page when it comes across a directory it can’t access.

    Thanks 😉

    Plugin Author Simon Prosser

    (@pross)

    I dont know much about windows im afraid, what if you add the .git dir to the group apache is running on?

    Thread Starter David Hancock

    (@davgothic)

    My bad, I’ve figured out that the problem is nothing to do with permissions.

    The problem is actually caused because on line 29 of main.php the script tries to access a directory (such as .git) using file_get_contents() and as it’s not a file, a warning is thrown.

    I propose the following change:

    if ( is_dir($filename) ) {
    	$other[$filename] = NULL;
    } else {
    	$other[$filename] = file_get_contents( $filename );
    }

    instead of:

    $other[$filename] = file_get_contents( $filename );

    That way the warnings will no longer occur but directories like .git will still be caught by the following checks such as WARNING: .git .gitignore .ds_store Hidden Files or Folders found..

    Plugin Author Simon Prosser

    (@pross)

    $other[$filename] = ( ! is_dir($filename) ) ? file_get_contents( $filename ) : NULL;

    Try that…

    Thread Starter David Hancock

    (@davgothic)

    Yeah either ternary operator or basic if condition will do, could you add it to the plugin in the next update please? 🙂

    Plugin Author Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Fixed in trunk.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: Theme-Check] file_get_contents warning with .git directories’ is closed to new replies.