• The line define( 'WP_CACHE', true ); is not removed from wp-config.php after deactivation / deletion of plugin.

    As a sidenote we would recommend better handling of return codes of functions, e.g. when dealing with wp-config.php in surge/include/install.php:

    $config = file_get_contents( $config_path );
    $pattern = '..removed..';
    $config = preg_replace( $pattern, '', $config );
    $bytes = file_put_contents( $config_path, $config );
    update_option( 'surge_installed', $bytes ? 1 : 2 );

    Theoretical code flow:

    If $config is false from file_get_contents() it will be empty at file_put_contents() which can return 0 written bytes which will write 2 in surge_installed which somewhere else might be interpreted as write-permission problem but actually isn’t.

    Not sure if this can ever happen, the recommendation comes from experience with typical problems which can arise when not checking return codes and/or not with identical comparison operator.

    WordPress 5.8.2, Twenty Twenty-One 1.4, Surge 1.0.1

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konstantin Kovshenin

    (@kovshenin)

    Thanks for your feedback!

    We specifically do not remove the WP_CACHE constant from wp-config.php at deactivation or during uninstall, because another page caching plugin may already be relying on that constant to be there. It doesn’t hurt, even if advanced-cache.php is missing.

    Re. file_get_contents(), sounds like an edge case, but will be happy to investigate further. Please use our issue tracker: https://github.com/kovshenin/surge

    Thanks again for your input!

    Thread Starter Ov3rfly

    (@ov3rfly)

    Remove what you add.

    Possible misinterpretation of file_put_contents() result 0 vs false is what caught our eye here first but of course every return code should be checked. We don’t use github, sorry.

    Plugin Author Konstantin Kovshenin

    (@kovshenin)

    Thank you for your feedback!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bug, WP_CACHE left behind in wp-config.php’ is closed to new replies.