• Resolved Eduardo Pittol

    (@edpittol)


    First of all, congratulations for the job with the plugin. It is a really good all in one performance WordPress toolkit.

    I work with versioned code and Docker to run the development environment. And I have issues with the way as the plugin work to apply the settings writing on the config files. I’m not against about that. But in my case, this broke my capability to version the code.

    To solve that I write some piece of code that undo the write made by W3TC.

    
    /**
     * Add action to undo the mechanism that generate automatically the nginx.conf
     * and the WP_CACHE definition to wp-config.php
     */
    function w3tc_admin_init() {
    	global $pagenow, $wp_config_backup;
    
    	$is_w3tc_page = \W3TC\Util_Admin::is_w3tc_admin_page();
    
    	if (
    		'plugins.php' === $pagenow ||
    		$is_w3tc_page ||
    		isset( $_REQUEST['w3tc_note'] ) ||
    		isset( $_REQUEST['w3tc_error'] ) ||
    		isset( $_REQUEST['w3tc_message'] )
    	) {
    		$config_path = \W3TC\Util_Environment::wp_config_path();
    		$wp_config_backup = @file_get_contents( $config_path );
    
    		add_action( 'admin_notices', 'odiario_w3tc_undo_filesystem_changes', 20 );
    	}
    }
    add_action( 'admin_init', 'w3tc_admin_init' );
    
    function w3tc_undo_filesystem_changes() {
    	global $wp_config_backup;
    
    	@unlink(\W3TC\Util_Rule::get_minify_rules_core_path());
    
    	try {
    		$config_path = \W3TC\Util_Environment::wp_config_path();
    		\W3TC\Util_WpFile::write_to_file( $config_path, $wp_config_backup );
    	} catch(Exception $e) {}
    }

    I don’t think a good solution because I continue receiving notices to update the code and restart the web server.

    My request is a flag that skip the file write system. Is this makes sense to the project?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @edpittol

    Thank you for your inquiry and I am happy to assist you with this.
    W3 Total Cache needs to write to those files and define(‘WP_CACHE’, true); or the caching will not work.
    Have you considered changing eh write permissions to those files and add the constants manually?
    Thanks

    Thread Starter Eduardo Pittol

    (@edpittol)

    I understand. I control this on my side using environment variable. So I can decide if I enable or not the cache. Normally it is deactivated, but if I want to test something I can enable and test easily on my local environment.

    I believe with this flag the developer must assumes the responsibility to manage the settings.

    Change the write permission would continue showing the messages on admin. And I don’t think a good experience.

    In my case I have another issue that I use Docker Sync and all files have www-data as owner. I could circumvent that.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @edpittol

    Thank you for the information.
    I understand what you are saying but this is needed in 90% of the cases.
    Understand that automation is something that is offering the users fewer worries especially for the users that are not tech-savvy.
    Thank yoU!

    Thread Starter Eduardo Pittol

    (@edpittol)

    Yes. I don’t imagine changing the default behaviour of the plugin. But a flag to change the behaviour in case like mine.

    So no possibility of that can be put on the roadmap?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Block file write’ is closed to new replies.