• I have been getting these errors on sites hosted on my server for a while now:

    [09-Sep-2021 18:48:05 UTC] PHP Warning: file_exists(): open_basedir restriction in effect. File(/wp-cache-blog17f7cbb9913f660d72e8e34c84e76cd5.php) is not within the allowed path(s): (/home/***/domains/***/:/home/***/domains/_codebase:/home/***/php_errors/:/tmp) in /home/***/domains/***/public_html/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 100

    What could be causing these errors?

Viewing 15 replies - 16 through 30 (of 40 total)
  • Thread Starter vespino

    (@vespino)

    That is correct.

    OK, I think that means there’s something odd about your server configuration. The path is run through the command realpath but something is going wrong there.

    Has your cache directory been created in the wp-content directory?

    Create a file called test.php in your site root folder (where wp-config.php, wp-atom.php, etc live) with this content:

    
    <?php
    
    if ( $_GET['test'] === 'abcdef' ) {
            require( './wp-load.php' );
            echo "1 path: " . WP_CONTENT_DIR . '/cache/<br />';
            echo "2 realpath: " . realpath( WP_CONTENT_DIR . '/cache/' );
    }
    

    Make sure you change “abcdef” to a random string, please!
    Now load that file through your web browser, pointing at https://example.com/test.php?test=123456 (exchange your hostname and secret string)
    You should see something like:
    1 path: /var/www/wp-content/cache/
    2 realpath: /var/www/wp-content/cache

    Do you see anything for “2” do you see the same path?

    Make sure to delete test.php afterwards.

    Thread Starter vespino

    (@vespino)

    This is the output:

    1 path: /home/***/domains/***/public_html/wp-content/cache/
    2 realpath: /home/***/domains/***/public_html/wp-content/cache

    Might the missing / be causing the issue?

    Thanks. Just makes it more confusing. ??

    What’s happening here:
    1. $blog_cache_dir is set in wp-cache-phase1.php on line 30 to the $cache_path.
    2. A bit later the plugin creates the $cache_file in wp_super_cache_init() using the realpath of $blog_cache_dir – that’s where things are going wrong.

    Can you edit wp-cache-phase2.php on your server and add two extra lines at line 70?

    
    wp_cache_debug( 'wp_super_cache_init: 1 blog_cache_dir: ' . $blog_cache_dir );
    wp_cache_debug( 'wp_super_cache_init: 2 real blog_cache_dir: ' . wpsc_get_realpath( $blog_cache_dir ) );
    

    Enable debugging in the plugin and look at the debug log. You might have to leave things run for a while until you start seeing the warning in your PHP error log. Should be easy to match timestamps in each log file.
    Is the “blog_cache_dir” correct in both log entries?

    Thread Starter vespino

    (@vespino)

    I have it running and will come back to you with the logs as soon as the error has occurred.

    Keep an eye on the size of that debug log. It will get very big if your site is active. If the errors don’t show up, it’s probably a good idea to delete the log and restart logging from the debug page every now and again.

    Thread Starter vespino

    (@vespino)

    @donncha this is my latest warning: [14-Dec-2021 08:23:00 UTC] PHP Warning: file_exists(): open_basedir restriction in effect. File(/wp-cache-dup-installerca0338eaff90b2a10ace5c64ebed9d9e.php) is not within the allowed path(s): (/home/***/domains/***/:/home/***/domains/_codebase:/home/***/php_errors/:/tmp) in /home/***/domains/***/public_html/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 100

    Do you want me to send you the debug log?

    • This reply was modified 2 years, 11 months ago by vespino.

    No, look for the two “wp_super_cache_init:” entries around 08:23:00 this morning in the debug log.

    Does the first one look correct and is the second one the same path, or is it blank or “/” ?

    Thread Starter vespino

    (@vespino)

    @donncha Unfortunately there aren’t any logs containing “wp_super_cache_init”.

    Thread Starter vespino

    (@vespino)

    @donncha 2 new warnings, still no log containing “wp_super_cache_init”.

    [14-Dec-2021 10:10:53 UTC] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/wp-cache-oldsite0e991bdd54795ac93db32687c9e9a8dc.php) is not within the allowed path(s): (/home/***/domains/***/:/home/***/domains/_codebase:/home/***/php_errors/:/tmp) in /home/***/domains/***/public_html/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 100
    [14-Dec-2021 10:13:36 UTC] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/wp-cache-oldsite13bf7ba4e51891d172077166d1aac026.php) is not within the allowed path(s): (/home/***/domains/***/:/home/***/domains/_codebase:/home/***/php_errors/:/tmp) in /home/***/domains/***/public_html/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 100

    I can’t explain how you’re seeing those without the debug entries. The code has to go through “wp_super_cache_init” to get to line 100 of that file.

    Is there any obvious pattern to those errors in other log files such as your access logs? Was it a particular URL that caused this warning?
    Is there anything at all in the debug log at that time?

    Thread Starter vespino

    (@vespino)

    @donncha here, have a look yourself… you probably know better where to look for: https://onetimesecret.com/secret/avphljaho1m70ukuxodeha2f646l55o

    Thanks for that link and your trust. I see it.

    It’s your oldsite page or URL.

    
    wpsc_get_realpath: directory does not exist - ABSPATH/wp-content/cache/blogs/oldsite/ 
    

    wp_super_cache_init calls wpsc_get_realpath to get the “real path” to the cache file but it should check that the real path returns a path, and not “false”. I’ll be able to fix that!

    Would you be willing to test the development version when I have a fix checked in? It’s very simple, just download a zip file and copy it into the plugins directory overwriting the wp-super-cache folder.

    Thread Starter vespino

    (@vespino)

    No worries! I would have no problems testing, but one thing: you’re referring to the oldsite directory, but I’m also getting this warnings on other sites I’m hosting and these sites don’t have that directory. I will keep an eye out for warnings on those sites. Do you want me to send you the logs when warnings start to appear?

    No need. I see where the bug is now. The $cache_file will have to be set to false to short circuit the code that serves the cache since it doesn’t exist. That’ll avoid the warning. ??

Viewing 15 replies - 16 through 30 (of 40 total)
  • The topic ‘open_basedir restriction’ is closed to new replies.