Support » Plugin: HTTP Headers » Failed to open stream after activate

  • After install WP 4.9.7 and activate, I get:
    PHP Warning: fopen(/home/xxxxxxx/public_html/my-domain.com/): failed to open stream: Is a directory in /home/xxxxxxx/public_html/my-domain.com/wp-admin/includes/misc.php on line 125

    What might be the reason?
    Note: I could not find any fopen call in the code.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Dimitar Ivanov

    (@zinoui)

    Hi @mullibahr

    This error comes from the WordPress function insert_with_markers. HTTP Headers plugin use this function to store your settings to .htacess or .user.ini

    The error is possible to occurs only if the PHP on your machine is using ‘cgi’ Server API and the same time:
    a) PHP have a version below 5.3.0
    b) user_ini.filename is empty

    Can you confirm this is your case? Then I will see how to fix it.

    The site is running PHP 7.2
    WP 5.1.1 (he-IL)
    .htaccess exists with permission 0644
    no user.ini or similar
    Hosted in Siteground (which may have their own user.ini…)

    Hope it helps!!!

    It seems that a check for file existence & write permissions is missing.
    Appropriate error message can hint the source of the problem.

    • This reply was modified 7 months, 4 weeks ago by mulli.bahr.
    • This reply was modified 7 months, 4 weeks ago by mulli.bahr.

    I found the place where the code breaks.

    The code assumes that ini_get('user_ini.filename') does not fail.
    In my setup, it does fail since the file does not exist, so ini_get returns FALSE!

    As a result – the error message on admin complains that ‘file not found’ – but fails to tell which file it was looking for! since ini_get() fails…
    Feature request: provide the name of the file to provide or generate it automatically!

    Please see the code below. Is it correct to use .htaccess in this case?

    PHP_SAPI occurs in 2 places. I did not look at the other one.

    function update_cookie_security_directives() {
        $lines = array();
        $is_apache = get_option('hh_method') == 'htaccess';
        $htaccess = get_home_path().'.htaccess';
        if (strpos(PHP_SAPI, 'cgi') !== false) {
            $iget = ini_get('user_ini.filename');
            if (!$iget || $iget == ""){
                error_log("iget FAILED = ". $iget);
                $filename = $htaccess;
            }else
                $filename = get_home_path().ini_get('user_ini.filename');
            $lines = php_cookie_security_directives();
        }

    I also get the following message on admin board upon activating the plugin:
    NOTE: it does not provide the file name required.

    Warning!
    The following file was not found. Please make sure the file exists and has write permissions: /home/my-directory/public_html/my-domain.com/
    • This reply was modified 7 months, 4 weeks ago by mulli.bahr.
    • This reply was modified 7 months, 4 weeks ago by mulli.bahr.
    • This reply was modified 7 months, 4 weeks ago by mulli.bahr.

    Further investigation shows that .user.ini file may not exist.
    I do not know how and if it is related to CGI at all, as the code suggests??
    From the documentation below, it exists only if INI setting modes are defined…

    Please advise. Thanks!

    Please see the folowing documentation

    Only INI settings with the modes PHP_INI_PERDIR and PHP_INI_USER will be recognized in .user.ini-style INI files.

    Two new INI directives, user_ini.filename and user_ini.cache_ttl control the use of user INI files.

    user_ini.filename sets the name of the file PHP looks for in each directory; if set to an empty string, PHP doesn’t scan at all. The default is .user.ini.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Failed to open stream after activate’ is closed to new replies.