• The wp_cache_get API has 2 parameters that are not presently being handled in the W3TC ObjectCache implementation. Other plugins and possibly WP depend on these parameters. Not properly implementing the current API could break or at least erode performance of WP and/or plugins.

    Please see:

    https://codex.www.ads-software.com/Function_Reference/wp_cache_get

    The missing parameters are $force, and $found.

    Specifically, $found causes problems for me, specifically with the WPML plugin.

    $found should be set by the ObjectCache plugin. WPML (and other plugins I would assume), test this variable to see if the lookup value was actually found in the cache. Usually, if $found is false, this means the expensive query is done, and the result is stored in the cache.

    Currently, $found is always false, which means the query is done all the time and performance is eroded.

    I think setting $found properly when the Object Cache is being used, would increase performance when the W3TC Object cache is being used.

    Thanks,
    Rich

    https://www.ads-software.com/plugins/w3-total-cache/

Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter awhig

    (@awhig)

    I really think this is a big issue for W3 Object Cache. Any code that uses wp_cache_get and uses the found parameter, is totally hosed, if they are using W3TC with object caching turned on.

    I’ve fixed my personal copy of w3tc ObjectCache, and I’ve reduced query usage, page load time, load on my DB, etc.

    It’s a very simple update. I went to see if I could contribute my code, but did not see a way to do this.

    I think everyone using W3TC would benefit from this fix!!!

    I also use the WPML plugin for site translations. This plugin adds quite of bit of queries to the site, and uses the “found” parameter when caching query results in a lot of places.

    Unfortunately, anyone using W3TC with object caching, is really being hurt by this bug.

    Rich

    Thread Starter awhig

    (@awhig)

    I’ve checked the code in the 0.9.4 release. It looks like this is still an issue. Is there any interest in fixing this?

    Thanks,
    Rich

    Is your fix very complex? Would you be able to post it to pastebin or similar?

    Unfortunately, anyone using W3TC with object caching, is really being hurt by this bug.

    Will W3TC (v. 0.9.4) still work and function correctly, but that the performance will not be as good as it could be?

    Thread Starter awhig

    (@awhig)

    W3TC still works, in that your site will still function.

    The Object cache though does not work for anything that tests the $found parameter to determine an object was actually found in the cache. Any performance gain the object cache offers is lost.

    The fix is rather simple.

    In lib/W3/ObjectCacheBridge.php

    change the get function to (line 27):

    function get($id, $group = 'default', $force = false, &$found = null) {
            $cache = $this->_get_engine($group);
            return $cache->get($id, $group, $force, $found);
        }

    In lib/W3/ObjectCache.php (line 153). I wanted to minimize code changes, so I avoided trying to rewrite this method…

    function get($id, $group = 'default', $force = false, &$found = null) {
            if ($this->_debug) {
                $time_start = w3_microtime();
            }
    
            $key = $this->_get_cache_key($id, $group);
            $internal = isset($this->cache[$key]);
    
            if ($internal) {
                $value = $this->cache[$key];
                $found = true;
            } elseif ($this->_caching &&
                      !in_array($group, $this->nonpersistent_groups) &&
                        $this->_check_can_cache_runtime($group)) {
                $cache = $this->_get_cache(null, $group);
                $v = $cache->get($key);
                if (is_array($v) && $v['content'] != null)
                {
                    $value = $v['content'];
                    $found = true;
                }
                else
                    $value = false;
            } else {
                $value = false;
            }
    
            if ($value === null) {
                $value = false;
            }
    
            if (is_object($value)) {
                $value = clone( $value );
            }
    
            $this->cache[$key] = $value;
            $this->cache_total++;
    
            if ($found){
                $cached = true;
                $this->cache_hits++;
            } else {
                $found = false;
                $cached = false;
                $this->cache_misses++;
            }
    
            /**
             * Add debug info
             */
            if ($this->_debug) {
                $time = w3_microtime() - $time_start;
                $this->time_total += $time;
    
                if (!$group) {
                    $group = 'default';
                }
    
                $this->debug_info[] = array(
                    'id' => $id,
                    'group' => $group,
                    'cached' => $cached,
                    'internal' => $internal,
                    'data_size' => ($value ? strlen(serialize($value)) : ''),
                    'time' => $time
                );
            }
    
            return $value;
        }
    Thread Starter awhig

    (@awhig)

    FYI,

    My code change does not implement the $force parameter, so if someone from the W3TC team decides to actually upgrade their implementation, they should probably do that as well.

    I was mainly concerned with $found.

    Thanks,
    Rich

    Yp. I had to uninstall it. It’s very disappointing because, as a fellow plugin developer, I always try to keep things symmetrical. I use Yoast, wanted to use MaxCDN with W3TC, but I am selling products on my site, and W3TC totally screwed up everything with this last update. So now I have a pull Zone for MaxCDN that I can’t even use.

    *****************************8

    W3 Total Cache Error: some files appear to be missing or out of place. Please re-install plugin or remove /home/axjem1/public_html/wp-content/advanced-cache.php.W3 Total Cache Error: some files appear to be missing or out of place. Please re-install plugin or remove /home/axjem1/public_html/wp-content/object-cache.php.
    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/axjem1/public_html/wp-content/advanced-cache.php:23) in /home/axjem1/public_html/wp-content/plugins/testimonial-basics/testimonial-basics.php on line 38

    Warning: Cannot modify header information – headers already sent by (output started at /home/axjem1/public_html/wp-content/advanced-cache.php:23) in /home/axjem1/public_html/wp-content/plugins/easy-digital-downloads/includes/libraries/class-wp-session.php on line 124

    Warning: Cannot modify header information – headers already sent by (output started at /home/axjem1/public_html/wp-content/advanced-cache.php:23) in /home/axjem1/public_html/wp-includes/option.php on line 563

    Warning: Cannot modify header information – headers already sent by (output started at /home/axjem1/public_html/wp-content/advanced-cache.php:23) in /home/axjem1/public_html/wp-includes/option.php on line 564

    ***********************************

    Here are the errors that I got on my dashboard header, even after I disabled the plugin.

    @jakzam I once went through a nightmare when I uninstalled on a site I removed it from. I disabled it and uninstalled it and my site crashed. The fix for me was to go in via FTP and remove advanced-cache.php, db.php, w3tc and w3 total cache config.php. I deleted the entire folders and all was OK.

    @awhig I have not updatedW3 yet, I am on version 0.9.3. Will your fix work on that version? I would only need to make the changes in lib/W3/ObjectCacheBridge.php right?

    @miz.Michele…yeah i know. I was hoping not to go through all that. I am a plugin developer here also. We have a few in the Directory and one Pro.

    For such a popular and highly recommended plugin by some of my top fellow developers, the lack of a complete uninstall in these cases is something that sets me back.

    I shouldn’t have to jump through hoops to get rid of every trace of any plugin. Many plugins that interact with the database have options to tick to remove all the db tables as well. Not to mention the various stray folders that don’t get included in the uninstall.

    I think the W3TC guys should not have rolled out so many changes in one update. The changelog is a full page long. And as widely used as it is, the hours of answering support should be a lesson learned in not jamming so much into one release.

    I had finally nailed down all the settings for my usual site setup. I just bought MaxCDN for running on our two main sites. I can’t use super cache with my theme. And the CDN Linker that can be used has no options, and therefore pushes ALL the files (or too many) through the CDN, breaking the site. So the only way I can use MaxCDN properly is with W3TC, but now it’s broken.

    I hope 0.9.5 comes out quickly.

    I didn’t know you were a developer :). I’m not but fairly astute and I’ve had a hard time with certain aspects with that plugin. When it crashed I was fairly new to WP and it took me over two hours to figure it out. I fully agree about not having to jump through hoops to uninstall.

    My two main use it because quite frankly I finally have it tweaked pretty well and to change over at this point will likely be all day event so I’ve been trying to avoid it if at all possible.

    On other sites that I have set up and/or that have crashed, I’ve used alternatives depending on the site setup. One uses Super Cache and although it has different content than my other sites, it runs the fastest.

    I don’t use MAX so that’s good to know and I haven’t upgraded to 0.9.4 yet.

    This is fixed in the next release, drop us an email if you’d like to try it https://www.w3-edge.com/contact/

    Thread Starter awhig

    (@awhig)

    Thank you.

    Rich

    any idea of ETA for the next release?

    Thank you for your response Willie, really appreciate that!

    Any idea when we should expect the next public release of W3TC? It was almost 8 months since the last one.

    @roam92: No ETA, but the version 0.9.4 was released 17 days ago… ??

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘ObjectCache API is out of date. This breaks other plugins’ is closed to new replies.