0

I have a sub-domain of the main domain which seems to be broken. The error states that "Server IP Address could not be found".

When I checked the logs I found the following error:

[04-Jun-2018 17:54:43 UTC] PHP Fatal error:  Cannot redeclare is_writeable_ACLSafe() (previously declared in /home/testcompany/public_html/wp-content/plugins/wp-super-cache/wp-cache-phase2.php:1009) in 

/home/testcompany/training.testcompany/wp-content/plugins/wp-super-cache/wp-cache.php on line 102


Line#102 belonging to the section

/home/thebettersoftwar/training.thebettersoftwarecompany.com/wp-content/plugins/wp-super-cache/wp-cache.php

function is_writeable_ACLSafe($path) {

    // PHP's is_writable does not work with Win32 NTFS

    if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
        return is_writeable_ACLSafe($path.uniqid(mt_rand()).'.tmp');
    else if (is_dir($path))
        return is_writeable_ACLSafe($path.'/'.uniqid(mt_rand()).'.tmp');
    // check tmp file for read/write capabilities
    $rm = file_exists($path);
    $f = @fopen($path, 'a');
    if ($f===false)
        return false;
    fclose($f);
    if (!$rm)
        unlink($path);
    return true;
}


The code belonging to this section

previously declared in /home/thebettersoftwar/public_html/wp-content/plugins/wp-super-cache/wp-cache-phase2.php:1009 is:

function is_writeable_ACLSafe( $path ) {

    // PHP's is_writable does not work with Win32 NTFS

    if ( $path[ strlen( $path ) - 1 ] == '/' ) { // recursively return a temporary file path
        return is_writeable_ACLSafe( $path . uniqid( mt_rand() ) . '.tmp' );
    } elseif ( is_dir( $path ) ) {
        return is_writeable_ACLSafe( $path . '/' . uniqid( mt_rand() ) . '.tmp' );
    }

    // check tmp file for read/write capabilities
    $rm = file_exists( $path );
    $f = @fopen( $path, 'a' );
    if ( $f === false )
        return false;
    fclose( $f );
    if ( ! $rm ) {
        unlink( $path );
    }

    return true;
}


Problem Statement:

I am wondering what changes I should make in the code above so that I am able to run the website live again.

flash
  • 1,455
  • 11
  • 61
  • 132
  • Wrap the function declaration in https://secure.php.net/manual/en/function.function-exists.php – castis Jun 04 '18 at 18:56
  • @castis Can you give me a pointer how to do that ? – flash Jun 04 '18 at 18:59
  • @castis I know its a duplicate but I wasn't able to get my answer. – flash Jun 04 '18 at 19:01
  • 1
    `if (!function_exists('is_writeable_ACLSafe')) { put function code in here }` – Danny Jun 04 '18 at 19:02
  • @Danny Are you talking about the 1st code or the 2nd one ? – flash Jun 04 '18 at 19:08
  • 1
    I do not know the order of includes so just wrap it around both. It will run the first time it's found since the function is not found and then not run the second time since it's been created whatever the order of includes are. – Danny Jun 04 '18 at 19:09
  • @user5447339 https://stackoverflow.com/a/17727695/2191572 – MonkeyZeus Jun 04 '18 at 19:13
  • By the looks of it both of these functions are declared in the source of wp-super-cache. I'd suggest re-installing the plugin as it seems to me like you've updated half the files and that function was moved from one file to another somewhere a long the line. – Arcath Jun 06 '18 at 14:50

0 Answers0