Title: Block file write
Last modified: April 30, 2020

---

# Block file write

 *  Resolved [Eduardo Pittol](https://wordpress.org/support/users/edpittol/)
 * (@edpittol)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/block-file-write/)
 * 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?
    -  This topic was modified 6 years, 1 month ago by [Eduardo Pittol](https://wordpress.org/support/users/edpittol/).
    -  This topic was modified 6 years, 1 month ago by [Eduardo Pittol](https://wordpress.org/support/users/edpittol/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/block-file-write/#post-12762893)
 * Hello [@edpittol](https://wordpress.org/support/users/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](https://wordpress.org/support/article/changing-file-permissions/)
   to those files and add the constants manually? Thanks
 *  Thread Starter [Eduardo Pittol](https://wordpress.org/support/users/edpittol/)
 * (@edpittol)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/block-file-write/#post-12766810)
 * 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](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [6 years ago](https://wordpress.org/support/topic/block-file-write/#post-12774076)
 * Hello [@edpittol](https://wordpress.org/support/users/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](https://wordpress.org/support/users/edpittol/)
 * (@edpittol)
 * [6 years ago](https://wordpress.org/support/topic/block-file-write/#post-12774307)
 * 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.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Eduardo Pittol](https://wordpress.org/support/users/edpittol/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/block-file-write/#post-12774307)
 * Status: resolved