Plugin Directory

Changeset 2000401


Ignore:
Timestamp:
12/22/2018 07:31:01 PM (7 years ago)
Author:
GatorDog
Message:

fix cache issue with nginx, remove cache when status transitioned away from publish

Location:
gator-cache/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • gator-cache/trunk/gator-cache.php

    r1814287 r2000401  
    22/**
    33 * @package Gator Cache
    4  * @version 2.1.7
     4 * @version 2.1.8
    55 */
    66/*
     
    1212Text Domain: gator-cache
    1313Domain Path: /lang
    14 Version: 2.1.7
     14Version: 2.1.8
    1515*/
    1616class WpGatorCache
     
    4949    protected static $multiSiteData;
    5050    const PREFIX = 'gtr_cache';
    51     const VERSION = '2.1.7';
     51    const VERSION = '2.1.8';
    5252    const JP_MOBILE_MOD = 'minileven'; // JetPack mobile module slug
    5353    const SUPPORT_LINK = 'https://wordpress.org/support/plugin/gator-cache';
     
    364364        }
    365365        $options = self::getOptions();
    366         GatorCache::getCache(
    367             $opts = GatorCache::getConfig(self::$configPath)->toArray()
    368         )->removeGroups($path, $groups = self::getCacheGroups($opts));
     366        if (false === ($cache = GatorCache::getCache($opts = GatorCache::getConfig(self::$configPath)->toArray()))) {
     367            return;
     368        }
     369        $cache->removeGroups($path, $groups = self::getCacheGroups($opts));
    369370        //purge the feed
    370371        if (!$options['skip_feeds']) {
    371             GatorCache::getCache($opts)->removeGroups('/comments/feed', $groups);
     372            $cache->removeGroups('/comments/feed', $groups);
    372373        }
    373374    }
     
    432433    {
    433434        $options = self::getOptions();
     435        if (false === ($cache = GatorCache::getCache($opts = GatorCache::getConfig(self::$configPath)->toArray()))) {
     436            return;
     437        }
    434438        if (empty($path)) {
    435             GatorCache::getCache(
    436                 $opts = GatorCache::getConfig(self::$configPath)->toArray()
    437             )->purgeGroups(self::getCacheGroups($opts));
    438             return;
    439         }
    440         GatorCache::getCache(
    441             $opts = GatorCache::getConfig(self::$configPath)->toArray()
    442         )->removeGroups($path, self::getCacheGroups($opts));
     439            $cache->purgeGroups(self::getCacheGroups($opts));
     440            return;
     441        }
     442        $cache->removeGroups($path, self::getCacheGroups($opts));
    443443    }
    444444
     
    781781            return;
    782782        }
    783         WpGatorCache::purgePath(false);
     783        // WpGatorCache::purgePath(false);
     784        WpGatorCache::flush();
    784785    }
    785786    // @note - the autoptimize plugin tries to call wp_cache_clear_cache before it's even loaded!!
  • gator-cache/trunk/lib/GatorCacheRefresh.php

    r1511312 r2000401  
    77    protected $refresh = false;
    88    protected $preTerms = array();
     9    protected $permalink = array();
    910
    1011    public function __construct($options, $configPath)
     
    2627            return;
    2728        }
     29        // get permalink here in pre-update in case the post is transitioned to draft or otherwise non-published
     30        $this->permalinks[$postId] = get_permalink($postId);
    2831        $post = array('ID' => $postId, 'post_type' => $postType);
    2932        if (false === ($taxonomies = $this->getArchiveTerms((object) $post))) {
     
    7679        //refresh parent posts and the current post
    7780        foreach (($posts = $this->getRefreshPosts($post, $newPost)) as $postId) {
    78             if (false !== ($path = parse_url(get_permalink($postId), PHP_URL_PATH))) {
     81            $permalink = $post->ID == $postId && isset($this->permalinks[$postId]) ? $this->permalinks[$postId] : get_permalink($postId);
     82            // var_dump($permalink);exit;
     83            if (false !== ($path = parse_url($permalink, PHP_URL_PATH))) {
    7984                $cache->removeGroups($path, $groups, true);
    8085            }
  • gator-cache/trunk/lib/Reo/Classic/Request.php

    r1068776 r2000401  
    936936        //@note seems that query_string should be used rather than parsing the uri
    937937        if (isset($this->server['QUERY_STRING'])) {
     938            // check for reverse proxy and remove url portion of query string
     939            if (isset($this->server['HTTP_X_ORIGINAL_URL']) && 0 === strpos($this->server['QUERY_STRING'], $path = $this->getPathInfo())) {
     940                $this->server['QUERY_STRING'] = substr($this->server['QUERY_STRING'], strlen($path));
     941            }
    938942            //normalize
    939943            if (strstr($this->server['QUERY_STRING'], '=') || strstr($this->server['QUERY_STRING'], '&')) {
     
    12421246    public function hasQueryString()
    12431247    {
    1244         return !empty($this->server['QUERY_STRING']);
     1248        return null !== $this->getQueryString();
    12451249    }
    12461250
  • gator-cache/trunk/readme.txt

    r1814287 r2000401  
    44Tags: cache, performance, optimize, bbpress, woocommerce, multisite, jetpack mobile
    55Requires at least: 3.8
    6 Tested up to: 4.9.2
    7 Stable tag: 2.1.7
     6Tested up to: 5.0.2
     7Stable tag: 2.1.8
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5555
    5656== Changelog ==
     57= 2.1.8 =
     58* Fix caching issue when Nginx is used as a reverse proxy
     59* Remove post from cache when transitioned from published (Switch to Draft)
     60* Verify compatiblity with latest version of WordPress
     61* Better error checking when cache directory is not found (due to migrations, etc)
    5762= 2.1.7 =
    5863* Compatiblity with recent versions of WooCommerce, will not cache cart, checkout or other pertinent pages
Note: See TracChangeset for help on using the changeset viewer.