Viewing 15 replies - 1 through 15 (of 21 total)
  • Plugin Author Emre Vona

    (@emrevona)

    you are right. this feature was like a beta feature. I will make it as a default feature and let you know.

    Thanks for your reply. I’d love to see an update for this feature.

    Today my site was broken again after an automatic update of the following plugins:

    – Elementor (from version 3.4.8 to 3.5.0)
    – Essential Addons for Elementor (from version 4.9.6 to 4.9.7)

    This happened though I had added these two lines to the wp-config.php:

    define("WPFC_CLEAR_CACHE_AFTER_PLUGIN_UPDATE", true);
    define("WPFC_CLEAR_CACHE_AFTER_THEME_UPDATE", true);

    Is there any reliable technique as of today, that I can use to prevent this?

    Plugin Author Emre Vona

    (@emrevona)

    are you using another cache system as well or any other optimization plugin?

    No, I don’t have any other caching / optimization plugin installed. Not sure how Elementor internally handles CSS, though.

    Plugin Author Emre Vona

    (@emrevona)

    is the problem solved when you clear all cache manually?

    Yes, that’s what I do to fix it.

    (I’m using the second option “Delete cache and minified CSS/JS”.)

    Plugin Author Emre Vona

    (@emrevona)

    I changed them to the following:

    if(defined("WPFC_CLEAR_CACHE_AFTER_PLUGIN_UPDATE") && WPFC_CLEAR_CACHE_AFTER_PLUGIN_UPDATE){
    	if(isset($_GET['DEBUG']) && $_GET['DEBUG']=='PLUGINS') { echo 'Clearing after plugin updates is activated!'; exit; }
    	add_action('upgrader_process_complete', array($this, 'clear_cache_after_update_plugin'), 10, 2);
    }
    
    if(defined("WPFC_CLEAR_CACHE_AFTER_THEME_UPDATE") && WPFC_CLEAR_CACHE_AFTER_THEME_UPDATE){
    	if(isset($_GET['DEBUG']) && $_GET['DEBUG']=='THEME') { echo 'Clearing after theme updates is activated!'; exit; }
    	add_action('upgrader_process_complete', array($this, 'clear_cache_after_update_theme'), 10, 2);
    }

    Calling https://www.mydomain.com/?DEBUG=PLUGINS and https://www.mydomain.com/?DEBUG=THEME I get the defined outputs and exits. I guess that is what you wanted to assure?

    Plugin Author Emre Vona

    (@emrevona)

    are they working properly?

    The debug flags that I added are working properly, yes.

    (But this isn’t a solution to the original problem.)

    Plugin Author Emre Vona

    (@emrevona)

    I have no idea.

    I added some debugging output to your plugin and traced down the issue. In the two functions you’re checking the type of update which is fine but also you are checking the list of affected plugins/themes. This is where the problem lies because the list of plugins/themes is not present when only a single plugin/theme gets an automatic update.

    The $options param looks like this in these situations:

    Array
    (
        [plugin] => elementor/elementor.php
        [type] => plugin
        [action] => update
    )

    To fix the issue please change these lines:

    public function clear_cache_after_update_plugin($upgrader_object, $options){
    	if($options['action'] == 'update'){
    		if($options['type'] == 'plugin' && isset($options['plugins'])){
    			$this->deleteCache(true);
    		}
    	}
    }
    
    public function clear_cache_after_update_theme($upgrader_object, $options){
    	if($options['action'] == 'update'){
    		if($options['type'] == 'theme' && isset($options['themes'])){
    			$this->deleteCache(true);
    		}
    	}
    }

    to the following:

    public function clear_cache_after_update_plugin($upgrader_object, $options){
    	if($options['action'] == 'update'){
    		if($options['type'] == 'plugin'){
    			$this->deleteCache(true);
    		}
    	}
    }
    
    public function clear_cache_after_update_theme($upgrader_object, $options){
    	if($options['action'] == 'update'){
    		if($options['type'] == 'theme'){
    			$this->deleteCache(true);
    		}
    	}
    }

    Or even shorter:

    public function clear_cache_after_update_plugin($upgrader_object, $options){
    	if($options['action'] == 'update' && $options['type'] == 'plugin'){
    		$this->deleteCache(true);
    	}
    }
    
    public function clear_cache_after_update_theme($upgrader_object, $options){
    	if($options['action'] == 'update' && $options['type'] == 'theme'){
    		$this->deleteCache(true);
    	}
    }
    Plugin Author Emre Vona

    (@emrevona)

    why should I remove the isset($options[‘plugins’]) condition? $options[‘plugins’] has already exist.

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Clear Cache after Automatic Updates’ is closed to new replies.