Giter VIP home page Giter VIP logo

szepeviktor / w3-total-cache-fixed Goto Github PK

View Code? Open in Web Editor NEW
237.0 45.0 47.0 4.34 MB

A community driven build of W3 Total Cache. The aim is to continuously incorporate fixes, improvements, and enhancements over the official WordPress release of W3 Total Cache.

Home Page: https://github.com/szepeviktor/w3-total-cache-fixed/releases

License: MIT License

PHP 95.93% HTML 0.01% Modelica 0.20% CSS 0.71% JavaScript 2.75% Shell 0.08% Java 0.29% VCL 0.04%
wordpress plugin w3tc w3totalcache cache

w3-total-cache-fixed's Introduction

W3 Total Cache (Fixed) Build Status

This project is a community driven build of W3 Total Cache (W3TC) originally developed by @ftownes. The aim is to continuously incorporate fixes, improvements, and enhancements over the official Wordpress release of W3 Total Cache.


Installation

  1. Deactivate and delete your existing W3 Total Cache plugin (if installed) from within WordPress' Plugin page.
  2. Use FTP or some other file manager to navigate to wp-content/plugins/.
  3. Download the latest release and extract its contents into wp-content/plugins/. The extracted directory name should be: w3-total-cache. If not, then rename it.
  4. Activate the W3 Total Cache (Fixed) plugin from within WordPress' Plugin page.
  5. Verify everything is working correctly and that your original configuration settings are still present.
  6. Empty all caches.

Fixes, Improvements, & Enhancement Highlights

For all changes by W3 Total Cache (Fixed) contributors (that were or not merged by W3 Total Cache official release), read the changelog.

Since the last official release of W3 Total Cache, the following new features, bug fixes, and updates have been applied to this repository's:

Type More Information
🪲 Bug Fix Fix for "Fatal error: Uncaught exception 'Exception' with message 'unknown engine'"
🪲 Bug Fix PHP Notice: Undefined index: minify in CacheFlush_Locally.php
🪲 Bug Fix PHP Notice: Undefined offset: 1 in Extension_CloudFlare_Plugin.php on line 376
🪲 Bug Fix Nginx: missing semicolon
🪲 Bug Fix Validate needle passed to stristr function

w3-total-cache-fixed's People

Contributors

amiga-500 avatar archon810 avatar charleslf avatar crevil avatar dsix-work avatar furniel avatar ivanner avatar jikamens avatar mrosenberg avatar nigrosimone avatar niklasfink avatar sbutler avatar szepeviktor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

w3-total-cache-fixed's Issues

Unit Testing + Travis CI

It’s super nice to have contributions from someone else but it’s hard to see if those changes break existing features. We all do mistakes from time to time and it’s easier to recover if you have good test coverage. Automated integration tests can help you out in these situations.

Is someone available in writing unit tests and integration with Trevis?

Updates and forks

I'm coming here from an issue posted to GitHub Updater, afragen/git-updater#460

If this fork would simply use GitHub Updater for updates and not delete or rename any repositories when installing I think your issues with updates, #115 #131 would go away. Updates would come from this plugin and not the main file.

Talk issue

@nigrosimone All of the todos are one-liners (OK, not 1 but maybe 5) except the OPcache compatibility which needs some research.

Have you met these problems?

You are free to send PR-s!

Installed this After Bad 0.9.5 Plugin Release -- One Issue

After having 0.9.5 crash my site, the new update is chock full of bugs, I decided to upload this GitHub fix version instead.

Everything seems fine, except I keep getting the alert to fix:

Edit file /usr/home/trailera/public_html/nginx.conf and replace all lines between and including # BEGIN W3TC Minify cache and # END W3TC Minify cache markers with:

I did the code exactly as it wanted, restarted nginx, and it still has the error. So not sure if the error just doesn't know to go away on this GitHub version (it doesn't exist on the 0.9.4 base), but want to make sure Minify is cacheing properly.

I can't just keep deleting and adding the same code, so hoping this is a common issue.

Cheers
Ryan

Server error 500 when Page Cache is enabled

Version 0.9.4.5.4 throughs server error 500 when Page Cache is enabled. I'm using PHP7.

My server error log shows:

  • PHP Parse error: syntax error, unexpected ‘<‘, expecting end of file in /home/mydomain.com/fghgh/public_html/wp-content/plugins/w3-total-cachelib/W3/PgCache.php(1511) : eval()'d code on line 1
  • PHP Fatal error: Exception thrown without a stack frame in Unknown on line 0

I also have the same error when using the latest official v0.9.5, the error log is then:

  • PHP Parse error: syntax error, unexpected ‘<‘, expecting end of file in /home/mydomain.com/fghgh/public_html/wp-content/plugins/w3-total-cache/PgCache_ContentGrabber.php(1460) : eval()’d code on line 1
  • PHP Fatal error: Exception thrown without a stack frame in Unknown on line 0

Any idea what goes wrong?

Object Cache not properly flushed

This is somehow related to #31

The symptoms are the same, and the culprit is in how flush() increments the key_version.

I found the following threads describing the same issue:

I see two possible ways for fixing this behavior:

  1. pass the right $group value from ObjectCache.php, and then figure out a way to increment the key_version for each $group when the flush() function is called
  2. Change the default $group value in the Cache folder from $group = '0' to $group = '' . Then all cache groups will be checking the key_version against the same key (i.e.: all $groups will be flushed at the same time and there would be no way for flushing just a single group, a functionality that doesn't seem to be implemented anyway)

The 2nd option seems the easiest way to go, as it appears that object cache groups are currently poorly implemented in W3TC. This was also the fix that Frederick Townes suggested in one of the above threads.

Thoughts?

Page Cache $key / Protocol Mismatch

This issue is to related to something that came up in #41 (comment)

What I think is happening is the following:

  • When an HTTPS page is cached, the cache's $key contains "_ssl" in the end.
  • When a flush is issued from the backend for a single page, the _flush_url() function in PgCacheFlush.php does not execute a flush for keys ending with "_ssl".

The culprit is in:

    function _get_encryptions() {
        $encryptions = array(false);
        if ($this->_config->get_boolean('pgcache.cache.ssl')) {
            $encryptions[] = 'ssl';
        }
        return $encryptions;
    }

So, the SSL cache is always created, but never flushed unless "pgcache.cache.ssl" key is set to true (i.e.: "Cache SSL (https) requests" in Performance => Page Cache)

This seems a bit redundant, so we should either enforce the above option and not create a cache entry for SSL pages if this is disabled, OR deprecate this option and always have SSL pages follow the default caching behavior.

Page cache exceptions won't work (ssl)

Hello. I noticed that there is something wrong with page cache exception rules. My website uses ssl. By default the option to cache https requests is disabled, so nothing gets cached. When I enable that option - almost everything gets cached, regardless of exceptions. For example, wp-login.php cached, pages with query strings - cached, even though the option to cache them is disabled. Only logged in users don't get cached. Defining DONOTPAGECACHE constant works, which is what I'm going to use, it is more flexible than regex matching rules anyway. Just wanted to report this issue.

[0.9.5] Flush disk enhanced cache not work

Issue with 0.9.5

From admin bar Performance > Page Modules > Page cache: current page don't work for me, not flush the current page cache.

I have a multisite installation path based with different site on some path, eg.:

http://yoursite.com/
http://yoursite.com/it/
http://yoursite.com/fr/

If i try to flush a page (not post) from admin bar Performance > Page Modules > Page cache: current page, eg.:

http://yoursite.com/fr/mypage/

delete() on Cache_File_Generic.php try to delete:

/wp-content/cache/page_enhanced/yoursite.com/_index.html
/wp-content/cache/page_enhanced/yoursite.com/_index.html_gzip
/wp-content/cache/page_enhanced/yoursite.com/wp-admin/network/admin.php/_index.htm
/wp-content/cache/page_enhanced/yoursite.com/wp-admin/network/admin.php/_index.html_gzip
/wp-content/cache/page_enhanced/yoursite.com/feed/_index.html
/wp-content/cache/page_enhanced/yoursite.com/feed/_index.html_gzip

the right file to delete:

/wp-content/cache/page_enhanced/yoursite.com/fr/mypage/_index.html
/wp-content/cache/page_enhanced/yoursite.com/fr/mypage/_index.html_gzip

are not in the list and the list has some mistakes:

/wp-content/cache/page_enhanced/yoursite.com/wp-admin/network/admin.php/_index.htm
/wp-content/cache/page_enhanced/yoursite.com/wp-admin/network/admin.php/_index.html_gzip

this make me crazy, w3tc seems to not have implemented the code for flush "page", i don't found it!

Page Cache Compatibility Mode

Howdy,

When upgrading sites that from 0.9.4.1 to today's pull, I encountered an error when compatibility mode was enabled. Our environment works fine with it off, so I have a work around.

I can replicate this on multiple sites and servers. The error looks like this:

[Tue Aug 30 18:15:28 2016] [crit] [client 24.56.43.116] configuration error: couldn't perform authentication. AuthType not set!: /wp-content/cache/page_enhanced/www.clientsite.com//category/faith//_index.html_gzip, referer: http://www.clientsite.com/

The pair of //'s in the path seem to be the culprit.

Sorry that I suck at coding or I'd be more useful and contribute fixes. I'm happy to test the latest code on some busy sites I manage & write up interesting things I find.

-J

Search not working

Hi,

Search in my site doesn't work when I use fix-w3tc.

Either with no cache plugin or the original W3TC, it works.

Can someone look into it?

Total Cache removes roles from $current_user

User bhamrick from the W3TC support forum on wordpress.org reported the following bug:

I’m trying to use the plugin Woocommerce CSV importer which enforces permissions by relying on the roles array on the $current_user object, as many other plugins do. W3 Total Cache is removing my ‘administrator’ role so $current_user->roles becomes an empty array. There are no actual DB changes, it just changes the value at runtime.

This looks to be an old bug, there’s a thread about the same issue from a year ago:
https://wordpress.org/support/topic/bug-w3tc-breaks-plugins-that-need-the-current-users-role/

I looked into it, and seems the bug has been there for more than a year.

The problem is with accessing the global variable $current_user and changing its fields when using array_shift.

A simple fix would be to replace array_shift() with reset() as mentioned in the linked thread above.

Taking it a step further, perhaps we should stop using the global variables altogether and get the $current_user by using:

$current_user = wp_get_current_user();

Is there any argument for using the global variable instead of calling the function? Maybe an overhead cost in execution time?

Stop updates from old version

It seems this fixed version wants to get updates from the old (Townes) version, when that one is updated. Instead, getting new versions from Github would be great. At least disable the updates from the Townes (non-fixed) version.

IE9 BUG: There are 5940 CSS rules in the stylesheet e0264.css - IE will ignore the last 844 rules!

W3TC merges all css in one file, but IE 9 handle only 4095 CSS rules per file.

IE 11 console show this error:

There are 4940 CSS rules in the stylesheet e0264.css - IE will ignore the last 844 rules!

Referring the following from Microsoft:

The rules for IE9 is: A sheet may contain up to 4095 selectors!

Any reason Dashboard's Buy Now Widget and General Setting's Licensing Widget are still visible?

Just curious...

I noticed the Dashboard's Buy Now Premium Service Widget (see 1st attached image) and the General Setting's Licensing widget (see 2nd attached image) are still showing.

Is there any reason for that?

Is it ok for me to remove them?

For reference, there respective code locations are here and here.

Because w3tc seems to have abandoned this plugin i fear if someone were using our fork that these two visible widgets would make user's mistakenly think a paid premium service is still offered by them only to find out in a very ugly way (after paying) that no such service exists and the protracted hassle of getting a credit card transaction reversal would have to begin.

Note: Their removals are part of PR #61

Dashboard: Premium Services Buy Now

dashboard_premium

General Settings: Licensing

general_settings_licensing

Page Cache $key / Host Mismatch

Hello,

I've been working with w3tc-fix on my local development environment and was having issues getting the cache to purge properly on when I would edit a post.

After a bit of debugging in /lib/W3/PgCache.php it appears that there was a mismatch between the $key and where the actual cache file was being saved due to my setup having a port number:

$key: localhost:8888/contact/_index.html
Actual location: localhost/contact/_index.html

So I made a few little edits to remove the port number and was able to get it working:

if ($request_uri){
     $is_ssl_request = ( strtolower(substr($request_uri, 0, 8)) == 'https://' );
     // $key = substr( $request_uri, $is_ssl_request ? 8 : 7 );

     // my additions begin
     $test_host = parse_url($request_uri, PHP_URL_HOST); 
     $test_path = parse_url($request_uri, PHP_URL_PATH);
     $test_key = $test_host . $test_path;
     $key = $test_key;
     // my additions end

} else {
     $key = $this->_request_host . $this->_request_uri;
}

Not sure if this would qualify as something worth submitting as it could somewhat of an edge case solution to my specific setup, but it seemed like it might be worth pointing out. Perhaps there is a more general purpose way to ensure the $key actually matches where the cache files are being saved.

Edit: and I know my code is not the best way of fixing this, but more of a little hacky thing to show the concept :)

Thank you,

Sitemap Page cache not flushed

This is related to something we've previously fixed in #32

In PgCache.php, there's the following lines:

        $group = '';
        if (!isset($this->_sitemap_matched)) {
            $sitemap_regex = $this->_config->get_string('pgcache.purge.sitemap_regex');
            if ($sitemap_regex && preg_match('/' . $sitemap_regex . '/', basename($this->_request_uri))) {
                $group = 'sitemaps';
                $this->_sitemap_matched = true;
            }
        } elseif ($this->_sitemap_matched)
            $group = 'sitemaps';

When using a caching method like Memcached or Redis, there's a case where $group may be equal to 'sitemaps', as per the above.

When this happens, a key is created in the caching engine, with the group sitemaps. However, when flush() is called in PgCacheFlush.php, no $group parameter is passed, which defaults to incrementing the key_version for only the default group (empty string), and the key with the 'sitemaps' group is not incremented.

This leads to problems with flushing a website's sitemap.

nginx enchanced broken

Is anyone notice that the page enchanced is not working properly (or maybe just me)

set $w3tc_ext "";
if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ua$w3tc_rewrite.html") {
    set $w3tc_ext .html;
}
if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ua$w3tc_rewrite.xml") {
    set $w3tc_ext .xml;
}
if ($w3tc_ext = "") {
  set $w3tc_rewrite 0;
}
if ($w3tc_rewrite = 1) {
    rewrite .* "/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ua$w3tc_rewrite$w3tc_ext" last;
}

the $w3tc_rewrite will have a value of 1 if rewrite should be performed (page exist in cache)
so by having $w3tc_rewrite in try files and rewrite section, the script will always fail.. because the file name don't have 1 on it .. .

for example for index page it is writen as _index.html where the nginx script try to find _index1.html

APC vs APCu

Hi guys,
I noticed APCu support.
Can anyone give any background to this, and what the consequences of using it are?

Is it a safe drop-in to use everywhere I would have used APC in w3tc? (I know enough to know it's different in that it doesn't have an opcode cache itself, but I don't know enought to know the consequences.)

Thanks.

Changelog and readme are out of date

I noticed the changelog.txt was both out of date and didn't may not appear to be updated with the Fix W3TC information. In fact, the changelog was talking about 0.9.3.

Just something minor.

mfunc removed from ConfigKeys.php?

Hi guys! Just a quesiton...

I was roaming master's ConfigKeys.php and noticed that mfunc is no longer listed. In 0.9.4.4-ConfigKeys.php mfunc was listed under the minify.html.comments.ignore array. There doesn't seem to be an explanation for its removal. Just wondering if that is a mistake or if it was done intentionally.

Thanks for the info
Kimberly

Undefined function apply_filters()

Hello, I have a problem with #50.

( ! ) Fatal error: Uncaught Error: Call to undefined function apply_filters() in C:\myproject\wp-content\plugins\w3-total-cache\lib\W3\PgCache.php on line 152
( ! ) Error: Call to undefined function apply_filters() in C:\myproject\wp-content\plugins\w3-total-cache\lib\W3\PgCache.php on line 152
Call Stack
#   Time    Memory  Function    Location
1   0.2007  386864  {main}( )   ...\index.php:0
2   0.2017  434288  require_once( 'C:\myproject\wp-admin\admin.php' )   ...\index.php:10
3   0.2025  448320  require_once( 'C:\myproject\wp-load.php' )  ...\admin.php:31
4   0.2029  477064  require_once( 'C:\myproject\wp-config.php' )    ...\wp-load.php:37
5   0.2036  551784  require_once( 'C:\myproject\wp-settings.php' )  ...\wp-config.php:176
6   0.2080  719672  include( 'C:\myproject\wp-content\advanced-cache.php' ) ...\wp-settings.php:74
7   0.2270  1542184 w3_instance( )  ...\advanced-cache.php:33
8   0.2287  1805152 W3_PgCache->__construct( )  ...\define.php:1471

apply_filters is defined in plugin.php, but no plugin.php in this context.

DB Cache not properly flushed

Hello,

I have noticed that the database cache was not being properly flushed if the cache method is anything other than disk (I tested it with memcached and redis).

The problem is with how flush_cache() is defined in DbCache.php
flush_cache() calls the flush() command defined in the cache engine.
For a disk-based cache, this results in the following line being executed:

        $flush_dir = $group ? $this->_cache_dir . DIRECTORY_SEPARATOR . $group . DIRECTORY_SEPARATOR : $this->_flush_dir;

since the flush() command was executed with no argument (ie: $group = ''), the $flush_dir defaults to the entire DB cache directory, which is properly deleted.

In memcached or redis, the flush() function actually increments the key_version for the different groups, but since the $group defaults to 0, the wrong key_version is being selected and incremented.

As a possible fix, we can change the flush_cache() function in DbCache.php to:

    function flush_cache() {
        $this->_flush_cache_group('all');
        return true;
    }

This will then loop through the different groups and clear each one of them.
This change can be found in here: charlesLF@b9e38ee

What are your thoughts on this one?

Minify error after deletion a plugin/theme

After deletion a plugin/theme, w3tc going in error:

Recently an error occurred while creating the CSS / JS minify cache: File "XXX" doesn't exist.

where XXX is the path of an assets of old plugin/theme.

the error persists after flushing all cache (object, db, minify, page).

I've seen a few old thread about this but no solution. In on thread Frederick said it would be fixed in a future version. That was a year ago, and obviously it's not fixed.

Prevent updating

Code suggestion if you want to prevent updating to W3 Total Cache plugin.

//* Disable plugin updates
add_filter('site_transient_update_plugins', 'disable_w3tc_plugin_updates');
function disable_w3tc_plugin_updates( $value ) {
    if( $value ) {
        unset( $value->response['w3-total-cache/w3-total-cache.php'] );
    }
    return $value;
}

Page cache priming does not work when 'priority' is missing in sitemap

I am seeing an issue with priming cache. But it's both in the original W3TC and fix-w3tc.

Earlier, with say, the default setting of priming 10 pages every 900 seconds, I used to see two primining jobs in cron. I use the plugin Crontrol to see cron events. One of these had "arguments" like [10], [20], [30] and so on after each interval of 900 seconds. But now the priming is not happening in both the W3TC and fix-w3tc.

Anyone has an idea on how to solve this?

Status: not cached on normal url when option to cache url with query strings is enabled

Hello. I think I've found another bug with caching exceptions. When the option to cache url with query strings is disabled, everything is ok. URLs without query strings are cached, ones with query strings are not:

Page without query:
Caching:            enabled
Status:             cached

Page with query:
Caching:            disabled
Reject reason:      Requested URI contains query
Status:             not cached

However, with the option to cache urls with query strings enabled, the results are:

Page without query:
Caching:            enabled
Status:             not cached

Page with query:
Caching:            enabled
Status:             cached

Note that caching is enabled, but status is not cached, which is strange. I don't know if it is just a debug error - pages are loading fast even when status is not cached and they seem to get cached. But I'm not sure if everything is ok.

By the way, in the second case, "page with query" is not just any page with a query. The query must have an effect on rendered content. But in the first case, any query will do to be treated as a page with query and be rejected from caching.

Access to global variable $wp_filter

As per this article: https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/ , the next WP version (4.7) will introduce changes to the $wp_filter global variable.

W3TC accesses this variable in 2 places in inc/functions/plugin.php:

$wp_filter[$hook] = array();

These seem to be (by default) only used in Genesis.php, but could be used by other developers.

I have never made use of this feature in W3TC, so I am not quite familiar with it, but we could either replace the above line with something like:

if(is_object( $wp_filter[$hook])) 
 $wp_filter[$hook]->callbacks = array();
else 
$wp_filter[$hook] = array();

or stick to WP standard functions and use remove_all_filters

I would prefer sticking to standard WP functions, even if there's a small execution overhead in doing so, but at least there's less chance of breaking things.

AMP Errors Revisited

Since I am not sure if the developers get notifications to closed issues, I am reopening #11 here.

I am still getting AMP errors.

A demo is here

Performance admin menu bar links to Support page

When you hover Performance in the Admin menu bar, there's a link to Support. That support page is a dead page that only says "Sorry, you are not allowed to access this page."

Admin menu bar

I believe that menu item should either be removed, or replaced with information leading to this repository and other useful information.

Add mfunc to ignored comment strings automaticallyc

If you are using the premium version of the plugin users will have the mfunc minified when using the HTML compressor this needs to be added by default in order to prevent user's fragment caching from not working.

Needs to be added to the Ignored comment stems

Looking for a solution now.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.