Commit 83c6944f authored by lucha's avatar lucha

[auto] plugin: wp-super-cache 1.4.9

parent 2e6b1bdc
2017-02-03 17:17 donncha
* readme.txt, wp-cache.php: Bump version number to 1.4.9 and update
changelog
2017-02-03 17:11 donncha
* wp-cache-phase1.php, wp-cache-phase2.php, wp-cache.php: * Github
merge:
* Make sure $cache_path has a trailing slash
(https://github.com/Automattic/wp-super-cache/pull/77)
* Remove flush()
(https://github.com/Automattic/wp-super-cache/pull/127) but also
check if headers are empty and flush and get headers again.
(https://github.com/Automattic/wp-super-cache/pull/179)
* Add fix for customizer
(https://github.com/Automattic/wp-super-cache/pull/161) and don't
cache PUT AND DELETE requests
(https://github.com/Automattic/wp-super-cache/pull/178)
* Check for superglobals before using them.
(https://github.com/Automattic/wp-super-cache/pull/131)
2017-02-03 16:54 donncha
* plugins/multisite.php, wp-cache-base.php, wp-cache.php: Github
merge: Need to check more than WP_ALLOW_MULTISITE to detect
multisite installs.
https://github.com/Automattic/wp-super-cache/issues/97
2017-02-03 15:07 donncha
* wp-cache-phase1.php: Github merge:
https://github.com/Automattic/wp-super-cache/pull/161 and also
don't cache PUT and DELETE requests (caught earlier than before)
2017-02-03 14:45 donncha
* plugins/jetpack.php: Remove extra ">", props @dd32
https://github.com/Automattic/wp-super-cache/pull/168
2017-02-03 14:37 donncha
* wp-super-cache.pot: Updated translation file
2017-02-03 14:33 donncha
* wp-cache.php: github merge: some of the changes that were
supposed to be checked in the previous merge didn't make it.
2017-02-03 10:18 donncha
* readme.txt: * Bump the tested version.
* Update the changelog
2017-02-03 10:13 donncha
* Changelog.txt: Updated changelog
2017-02-02 18:14 donncha
* readme.txt: Updated readme.txt changelog and docs
2017-02-02 18:08 donncha
* ossdl-cdn.php, readme.txt, wp-cache-phase2.php, wp-cache.php:
Sync with GITHUB:
* Don't delete so many files on blogs with static homepages.
https://github.com/Automattic/wp-super-cache/pull/175
* Discourage use of file locking because semaphores cause
problems and it's not needed.
https://github.com/Automattic/wp-super-cache/pull/174
* Reorganise the settings page in small ways
https://github.com/Automattic/wp-super-cache/pull/173
* Fixed XSS in settings page. Props @jaypatel
https://github.com/Automattic/wp-super-cache/pull/172
2017-01-11 16:58 kraftbj
* readme.txt, wp-cache-phase2.php: Github #138: Do not cache
PUT/DELETE requests
2016-12-09 15:38 kraftbj
* wp-cache-phase2.php: Check that header parts exist to avoid
`Undefined Index` notices
2016-12-09 15:37 kraftbj
* wp-cache-phase2.php: Update to Git master
2016-12-09 10:25 donncha
* readme.txt: Bump the "tested up to" value
2016-08-01 20:39 kraftbj
* readme.txt: Bump tested version to 4.6
2016-05-09 14:56 kraftbj
* readme.txt: Bump tested version
2016-03-07 15:24 kraftbj
* readme.txt: Update readme for previous commit
2016-03-07 15:20 kraftbj
* wp-cache-phase2.php: Catch up SVN to GH
2016-03-07 13:46 donncha
* readme.txt, wp-cache.php: Bumped version to 1.4.8 and updated
changelog
2016-03-07 13:39 donncha
* wp-super-cache.pot: Updated translation pot file
2016-03-07 12:37 donncha
* wp-cache.php: Remove this link as Google is reporting it as
malware. It's still available at
https://web.archive.org/web/20150914095007/http://bytes.com/topic/php/answers/3917-seconds-converted-hh-mm-ss.
Ref: https://github.com/Automattic/wp-super-cache/issues/106
2015-12-16 18:14 kraftbj
* readme.txt, wp-cache.php: Update readme for 1.4.7
2015-12-16 16:59 kraftbj
* wp-cache.php: Fix settings page layout breakage in 4.4.
2015-12-02 15:50 kraftbj
* ossdl-cdn.php, wp-cache.php: Corrects typos. See
https://github.com/Automattic/wp-super-cache/issues/81
props https://github.com/christophherr
2015-10-21 19:54 kraftbj
* wp-cache-phase1.php: Remove variable no longer defined after
previous update.
2015-10-09 18:06 donncha
* Changelog.txt, readme.txt, wp-cache.php: Bump version to 1.4.6
and update changelog
2015-10-08 17:14 donncha
* wp-cache.php: Don't check if .htaccess already created as the
......
......@@ -132,6 +132,8 @@ function scossdl_off_options() {
update_option('ossdl_off_include_dirs', $_POST['ossdl_off_include_dirs'] == '' ? 'wp-content,wp-includes' : $_POST['ossdl_off_include_dirs']);
update_option('ossdl_off_exclude', $_POST['ossdl_off_exclude']);
update_option('ossdl_cname', $_POST['ossdl_cname']);
if ( !isset( $_POST[ 'ossdl_https' ] ) )
$_POST[ 'ossdl_https' ] = 0;
update_option('ossdl_https', (int)$_POST['ossdl_https']);
if ( isset( $_POST[ 'ossdlcdn' ] ) ) {
$ossdlcdn = 1;
......@@ -163,7 +165,7 @@ function scossdl_off_options() {
<tr valign="top">
<th scope="row"><label for="ossdl_off_cdn_url"><?php _e( 'Off-site URL', 'wp-super-cache' ); ?></label></th>
<td>
<input type="text" name="ossdl_off_cdn_url" value="<?php echo(get_option('ossdl_off_cdn_url')); ?>" size="64" class="regular-text code" /><br />
<input type="text" name="ossdl_off_cdn_url" value="<?php echo esc_url( get_option( 'ossdl_off_cdn_url' ) ); ?>" size="64" class="regular-text code" /><br />
<span class="description"><?php printf( __( 'The new URL to be used in place of %1$s for rewriting. No trailing <code>/</code> please.<br />Example: <code>%2$s</code>.', 'wp-super-cache' ), get_option( 'siteurl' ), $example_cdn_uri ); ?></span>
</td>
</tr>
......
......@@ -25,7 +25,7 @@ function wp_super_cache_jetpack_admin() {
<h4><?php _e( 'Jetpack Mobile Theme', 'wp-super-cache' ); ?></h4>
<?php
if ( false == file_exists( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' ) ) {
echo "<strong>" . sprintf( __( "Jetpack not found in %s. Install it and enable the mobile theme and this helper plugin to cache visits by mobile visitors." ), dirname( WPCACHEHOME ) ) . "</strong>>";
echo "<strong>" . sprintf( __( "Jetpack not found in %s. Install it and enable the mobile theme and this helper plugin to cache visits by mobile visitors." ), dirname( WPCACHEHOME ) ) . "</strong>";
} else { ?>
<form name="wp_manager" action="" method="post">
<label><input type="radio" name="cache_jetpack" value="1" <?php if( $cache_jetpack ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
......
<?php
if ( defined( 'WP_ALLOW_MULTISITE' ) )
if ( ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) )
add_cacheaction( 'add_cacheaction', 'wp_super_cache_multisite_init' );
function wp_super_cache_multisite_init() {
......
=== WP Super Cache ===
Contributors: donncha, automattic, kraftbj
Tags: performance,caching,wp-cache,wp-super-cache,cache
Tested up to: 4.5.2
Stable tag: 1.4.8
Tested up to: 4.7.3
Stable tag: 1.4.9
Requires at least: 3.0
A very fast caching engine for WordPress that produces static html files.
......@@ -58,11 +58,26 @@ The cache directory, usually wp-content/cache/ is only for temporary files. Do n
== Upgrade Notice ==
= 1.4.8 =
Removed malware URL in a code comment.
= 1.4.9 =
Fixed XSS on the settings page, settings page updates, file locking fixes and PHP 7.1 fix, caching fixes on static homepage blogs and more.
== Changelog ==
= 1.4.9 =
* Fixed bug when not running sem_remove after sem_release. See https://github.com/Automattic/wp-super-cache/issues/85
* Fixed a PHP error impacting PHP 7.1.
* Fixed a bug where we cached PUT and DELETE requests. We're treating them like POST requests now.
* Delete supercache cache files, even when supercache is disabled, because mod_rewrite rules might still be active.
* Updated the settings page, moving things around. [#173](https://github.com/Automattic/wp-super-cache/pull/173)
* Make file locking less attractive on the settings page and fixed the WPSC_DISABLE_LOCKING constant so it really disables file locking even if the user has enabled it already.
* Added a WPSC_REMOVE_SEMAPHORE constant that must be defined if sem_remove() is to be used as it may cause problems. [#174](https://github.com/Automattic/wp-super-cache/pull/174)
* Added a "wpsc_delete_related_pages_on_edit" filter that on returning 0 will disable deletion of pages outside of page being edited. [#175](https://github.com/Automattic/wp-super-cache/pull/175)
* Fixed plugin deleting all cached pages when a site had a static homepage. [#175](https://github.com/Automattic/wp-super-cache/pull/175)
* Make sure $cache_path has a trailing slash [#177](https://github.com/Automattic/wp-super-cache/pull/77)
* Remove flush() [#127](https://github.com/Automattic/wp-super-cache/pull/127) but also check if headers are empty and flush and get headers again. [#179](https://github.com/Automattic/wp-super-cache/pull/179)
* Add fix for customizer [#161](https://github.com/Automattic/wp-super-cache/pull/161) and don't cache PUT AND DELETE requests [#178](https://github.com/Automattic/wp-super-cache/pull/178)
* Check for superglobals before using them. [#131](https://github.com/Automattic/wp-super-cache/pull/131)
= 1.4.8 =
* Removed malware URL in a code comment. (harmless to operation of plugin but gets flagged by A/V software)
* Updated translation file.
......@@ -187,7 +202,7 @@ Removed malware URL in a code comment.
* Serve repeated static files from the same CDN hostname.
* Updated translations.
* Make supercache dir lowercase to avoid problems with unicode URLs.
* Add option to skip https loaded static content.
* Add option to skip https loaded static content.
* Remove 5 second check on age of existing cache files. Should help with posts that get lots of comments and traffic.
* Lots of bugs fixed.
......@@ -273,12 +288,11 @@ Removed malware URL in a code comment.
* Fixed problem deleting cache file.
* Don't delete cache files when moderated comments are deleted.
= 0.9.7 =
* Fixed problem with blogs in folders.
* Added cache file listing and delete links to admin page.
* Added "Newest Cached Pages" listing in sidebox.
* Made admin page translatable.
* Made admin page translatable.
* Added "How do I make certain parts of the page stay dynamic?" to FAQ.
* Advanced: added "late init" feature so that plugin activates on "init". Set $wp_super_cache_late_init to true in config file to use.
* Disable supercaching when GET parameters present instead of disabling all caching. Disable on POST (as normal) and preview.
......@@ -299,7 +313,7 @@ Removed malware URL in a code comment.
* Add uninstall.php uninstall script.
* Updated cache/.htaccess rules (option to upgrade that)
* Added FAQ about category and static homepage problem.
* Add wp_cache_user_agent_is_rejected() back to wp-cache-phase2.php
* Add wp_cache_user_agent_is_rejected() back to wp-cache-phase2.php
* Show message for logged in users when caching disable for them.
* Check filemtime on correct supercache file
......@@ -320,67 +334,7 @@ Removed malware URL in a code comment.
6. Fixed problems with posts and comments not refreshing.
== Installation ==
1. You should have the Apache mod mime and mod rewrite modules installed and WordPress custom permalinks (Settings->Permalinks) enabled. PHP safe mode should be disabled. If any of those are missing or off you can still use PHP or legacy caching.
2. If you have WP-Cache installed already, please disable it. Edit wp-config.php and make sure the WP_CACHE and WPCACHEHOME defines are deleted, and remove the files wp-content/wp-cache-config.php and wp-content/advanced-cache.php. These will be recreated when you install this plugin.
3. Upload this directory to your plugins directory. It will create a 'wp-content/plugins/wp-super-cache/' directory.
4. If you are using WordPress MU or WordPress Multisite you can install the plugin in the ordinary plugins folder and activate it "network wide".
5. WordPress users should go to their Plugins page and activate "WP Super Cache".
6. Now go to Settings->WP Super Cache and enable caching. If you see an error message or a blank screen see the "FAQ" section later in this readme for instructions.
7. If you choose "Mod Rewrite caching", mod_rewrite rules will be inserted into your .htaccess file. Look in your web root directory for this file. It should look similar to this:
`-----------------.htaccess-----------------`
`RewriteEngine On`
`RewriteBase /`
`RewriteCond %{REQUEST_METHOD} !=POST`
`RewriteCond %{QUERY_STRING} !.*=.*`
`RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$`
`RewriteCond %{HTTP:Accept-Encoding} gzip`
`RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*`
`RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f`
`RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]`
`RewriteCond %{REQUEST_METHOD} !=POST`
`RewriteCond %{QUERY_STRING} !.*=.*`
`RewriteCond %{QUERY_STRING} !.*attachment_id=.*`
`RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$`
`RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*`
`RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f`
`RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]`
`RewriteCond %{REQUEST_FILENAME} !-f`
`RewriteCond %{REQUEST_FILENAME} !-d`
`RewriteRule . /index.php [L]`
`-----------------.htaccess-----------------`
8. After you have enabled the plugin, look for the file "wp-content/cache/.htaccess". If it's not there you must create it. It should read:
`# BEGIN supercache`
`<IfModule mod_mime.c>`
` <FilesMatch "\.html\.gz$">`
` ForceType text/html`
` FileETag None`
` </FilesMatch>`
` AddEncoding gzip .gz`
` AddType text/html .gz`
`</IfModule>`
`<IfModule mod_deflate.c>`
` SetEnvIfNoCase Request_URI \.gz$ no-gzip`
`</IfModule>`
`<IfModule mod_headers.c>`
` Header set Cache-Control 'max-age=3, must-revalidate'`
`</IfModule>`
`<IfModule mod_expires.c>`
` ExpiresActive On`
` ExpiresByType text/html A3`
`</IfModule>`
``
`# END supercache`
9. Apache must be configured to allow the modules above. If you receive a "500 internal error" when serving requests to anonymous users you need to dig into your Apache configuration. This configuration in my virtual host works for me:
`<Directory /home/www/>`
`AllowOverride All`
`</Directory>`
10. wp-content/advanced-cache.php loads the caching engine. This file is generated by the plugin. It uses the constant WPCACHEHOME to load the caching engine.
Install like any other plugin, directly from your plugins page but make sure you have custom permalinks enabled. Go to the plugin settings page at Settings->WP Super Cache and enable caching.
== How to uninstall WP Super Cache ==
......@@ -406,7 +360,9 @@ To manually uninstall:
= How do I know my blog is being cached? =
Enable debugging in the plugin settings page and load the log file in a new browser tab. Then view your blog while logged in and logged out. You should see activity in the log. View the source of any page on your site. When a page is first created, you'll see the text "Dynamic page generated in XXXX seconds." and "Cached page generated by WP-Super-Cache on YYYY-MM-DD HH:MM:SS" at the end of the source code. On reload, a cached page will show the same timestamp so wait a few seconds before checking.
Go to Settings->WP Super Cache and look for the "Cache Tester" form on the easy settings page. Click "Test Cache" and the plugin will request the front page of the site twice, comparing a timestamp on each to make sure they match.
If you want to do it manually, enable debugging in the plugin settings page and load the log file in a new browser tab. Then view your blog while logged in and logged out. You should see activity in the log. View the source of any page on your site. When a page is first created, you'll see the text "Dynamic page generated in XXXX seconds." and "Cached page generated by WP-Super-Cache on YYYY-MM-DD HH:MM:SS" at the end of the source code. On reload, a cached page will show the same timestamp so wait a few seconds before checking.
In legacy caching mode, if you have compression enabled, the text "Compression = gzip" will be added. If compression is disabled and the page is served as a static html file, the text "super cache" will be added. The only other way to check if your cached file was served by PHP script or from the static cache is by looking at the HTTP headers. PHP cached pages will have the header "WP-Super-Cache: Served supercache file from PHP". Legacy cached files will have the header, "WP-Super-Cache: Served legacy cache file". I used the <a href="https://addons.mozilla.org/en-US/firefox/addon/3829">Live HTTP Headers</a> extension for Firefox to examine the headers. You should also check your cache directory in wp-content/cache/supercache/hostname/ for static cache files.
If the plugin rules are missing from your .htaccess file, the plugin will attempt to serve the super cached page if it's found. The header "WP-Super-Cache: Served supercache file from PHP" if this happens.
......@@ -415,13 +371,9 @@ If the plugin rules are missing from your .htaccess file, the plugin will attemp
WP-Cache files are stored in wp-content/cache/ (or on MU sites in a blogs sub directory) and are named wp-cache-XXXXXXXXXXXXXXXXX.html. Associated meta files are stored in a meta sub directory. Those files contain information about the cached file. These files are generated by the "legacy caching" code in the plugin.
Supercache files are stored in wp-content/cache/supercache/HOSTNAME/ where HOSTNAME is your domain name. The files are stored in directories matching your site's permalink structure.
= Why is WP-Super-Cache better than WP-Cache? =
This plugin is based on the excellent WP-Cache plugin. Besides the caching WP-Cache did this plugin creates copies of every page that is accessed on a blog in a form that is quickly served by the web server. It's almost as quick as if the you had saved a html page in your browser and uploaded it to replace your homepage.
= Will comments and other dynamic parts of my blog update immediately? =
Comments will show as soon as they are moderated, depending on the comment policy of the blog owner. Other dynamic elements on a page may not update unless they are written in Javascript, Flash, Java or another client side browser language. The plugin really produces static html pages. No PHP is executed when those pages are served. "Popularity Contest" is one such plugin that will not work.
Comments will show as soon as they are moderated, depending on the comment policy of the blog owner. Other dynamic elements on a page may not update unless they are written in Javascript, Flash, Java or another client side browser language. The plugin really produces static html pages. No PHP is executed when those pages are served. "Popularity Contest" is one such plugin that will not work.
= Will the Super Cache compression slow down my server? =
......@@ -559,6 +511,7 @@ If that doesn't work, add this line to your wp-config.php:
`AddDefaultCharset CHARSET`
27. Use [Cron View](http://wordpress.org/plugins/cron-view/) to help diagnose garbage collection and preload problems. Use the plugin to make sure jobs are scheduled and for what time. Look for the wp_cache_gc and wp_cache_full_preload_hook jobs.
18. The error message, "WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory." appears at the end of every page. You can delete wp-content/advanced-cache.php and reload the plugin settings page or edit wp-config.php and look for WPCACHEHOME and make sure it points at the wp-super-cache folder. This will normally be wp-content/plugins/wp-super-cache/ but you'll likely need the full path to that file (so it's easier to let the settings page fix it). If it is not correct the caching engine will not load.
19. If your server is running into trouble because of the number of semaphores used by the plugin it's because your users are using file locking which is not recommended (but is needed by a small number of users). You can globally disable file locking by defining the constant WPSC_DISABLE_LOCKING, or defining the constant WPSC_REMOVE_SEMAPHORE so that sem_remove() is called after every page is cached but that seems to cause problems for other processes requesting the same semaphore. Best to disable it.
== CDN ==
......@@ -578,8 +531,8 @@ Three hooks are available:
2. 'add_cacheaction' - runs in phase2. Allows a plugin to add WordPress hooks.
3. 'cache_admin_page' - runs in the admin page. Use it to modify that page, perhaps by adding new configuration options.
There is one regular WordPress filter too. Use the "do_createsupercache" filter
to customize the checks made before caching. The filter accepts one parameter.
There is one regular WordPress filter too. Use the "do_createsupercache" filter
to customize the checks made before caching. The filter accepts one parameter.
The output of WP-Cache's wp_cache_get_cookies_values() function.
See plugins/searchengine.php as an example I use for my [No Adverts for Friends](http://z9.io/no-adverts-for-friends/) plugin.
......@@ -603,11 +556,11 @@ Translators who did a great job converting the text of the plugin to their nativ
* Tai (Japanese)
* [Vitaly](http://pressword.com.ua/wordpress/) (Ukranian)
* [Pseric](http://pseric.com/) and [Priv](http://priv.tw/blog) (Traditional Chinese)
* [Maître Mô](http://maitremo.fr/) (French)
* [Matre M](http://maitremo.fr/) (French)
* [Mathias Roth](http://trade-service.eu/) (German)
* Bar¿¿ Ünver (Turkish)
* Bar�� �nver (Turkish)
* [Elvis Fweb](http://wp.turkenichev.ru/) (Russian)
* Fredrik Forséll (Swedish)
* Fredrik Forsll (Swedish)
* [Alyona Lompar](http://wwww.webhostinggeeks.com/) (Ukranian)
* [Nata Strazda](http://www.webhostingrating.com/) (Lithuanian)
* [Alexander Alexandrov](http://www.designcontest.com/) (Belarusian)
......
......@@ -5,7 +5,7 @@ $WPSC_HTTP_HOST = htmlentities( $_SERVER[ 'HTTP_HOST' ] );
// We want to be able to identify each blog in a WordPress MU install
$blogcacheid = '';
if ( defined( 'VHOST' ) || ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) ) {
if ( ( defined( 'WP_ALLOW_MULTISITE' ) && constant( 'WP_ALLOW_MULTISITE' ) == true ) || defined( 'SUBDOMAIN_INSTALL' ) || defined( 'VHOST' ) || defined( 'SUNRISE' ) ) {
$blogcacheid = 'blog'; // main blog
if( defined( 'SUBDOMAIN_INSTALL' ) && constant( 'SUBDOMAIN_INSTALL' ) == true ) {
$blogcacheid = $WPSC_HTTP_HOST;
......
......@@ -47,8 +47,10 @@ if ( isset( $wp_cache_make_known_anon ) && $wp_cache_make_known_anon )
do_cacheaction( 'cache_init' );
if (!$cache_enabled || $_SERVER["REQUEST_METHOD"] == 'POST')
if ( ! $cache_enabled || ( isset( $_SERVER["REQUEST_METHOD"] ) && in_array( $_SERVER["REQUEST_METHOD"], array( 'POST', 'PUT', 'DELETE' ) ) ) || isset( $_GET['customize_changeset_uuid'] ) ) {
return true;
}
$file_expired = false;
$cache_filename = '';
......@@ -99,9 +101,11 @@ $wp_start_time = microtime();
function get_wp_cache_key( $url = false ) {
global $wp_cache_request_uri, $wp_cache_gzip_encoding, $WPSC_HTTP_HOST;
if ( !$url )
if ( ! $url ) {
$url = $wp_cache_request_uri;
return do_cacheaction( 'wp_cache_key', $WPSC_HTTP_HOST . intval( $_SERVER[ 'SERVER_PORT' ] ) . preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $url ) ) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values() );
}
$server_port = isset( $_SERVER[ 'SERVER_PORT' ] ) ? intval( $_SERVER[ 'SERVER_PORT' ] ) : 0;
return do_cacheaction( 'wp_cache_key', $WPSC_HTTP_HOST . $server_port . preg_replace('/#.*$/', '', str_replace( '/index.php', '/', $url ) ) . $wp_cache_gzip_encoding . wp_cache_get_cookies_values() );
}
function wp_super_cache_init() {
......
......@@ -121,12 +121,18 @@ if ( !function_exists( 'wp_cache_user_agent_is_rejected' ) ) {
function wp_cache_get_response_headers() {
if(function_exists('apache_response_headers')) {
flush();
$headers = apache_response_headers();
if ( empty( $headers ) ) {
flush();
$headers = apache_response_headers();
}
} else if(function_exists('headers_list')) {
$headers = array();
foreach(headers_list() as $hdr) {
list($header_name, $header_value) = explode(': ', $hdr, 2);
$header_parts = explode( ':', $hdr, 2 );
$header_name = isset( $header_parts[0] ) ? trim( $header_parts[0] ) : '';
$header_value = isset( $header_parts[1] ) ? trim( $header_parts[1] ) : '';
$headers[$header_name] = $header_value;
}
} else
......@@ -155,7 +161,7 @@ function wp_cache_is_rejected($uri) {
function wp_cache_mutex_init() {
global $mutex, $wp_cache_mutex_disabled, $use_flock, $blog_cache_dir, $mutex_filename, $sem_id;
if( isset( $wp_cache_mutex_disabled) && $wp_cache_mutex_disabled )
if ( defined( 'WPSC_DISABLE_LOCKING' ) || ( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled ) )
return true;
if( !is_bool( $use_flock ) ) {
......@@ -172,14 +178,14 @@ function wp_cache_mutex_init() {
$mutex = @fopen( $blog_cache_dir . $mutex_filename, 'w' );
} else {
wp_cache_debug( "Created mutex lock on semaphore: {$sem_id}", 5 );
$mutex = @sem_get( $sem_id, 1, 0644 | IPC_CREAT, 1 );
$mutex = @sem_get( $sem_id, 1, 0666, 1 );
}
}
function wp_cache_writers_entry() {
global $mutex, $wp_cache_mutex_disabled, $use_flock;
if( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled )
if ( defined( 'WPSC_DISABLE_LOCKING' ) || ( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled ) )
return true;
if( !$mutex ) {
......@@ -192,7 +198,7 @@ function wp_cache_writers_entry() {
flock($mutex, LOCK_EX);
} else {
wp_cache_debug( "grabbing lock using sem_acquire()", 5 );
sem_acquire($mutex);
@sem_acquire($mutex);
}
return true;
......@@ -201,7 +207,7 @@ function wp_cache_writers_entry() {
function wp_cache_writers_exit() {
global $mutex, $wp_cache_mutex_disabled, $use_flock;
if( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled )
if ( defined( 'WPSC_DISABLE_LOCKING' ) || ( isset( $wp_cache_mutex_disabled ) && $wp_cache_mutex_disabled ) )
return true;
if( !$mutex ) {
......@@ -211,10 +217,12 @@ function wp_cache_writers_exit() {
if ( $use_flock ) {
wp_cache_debug( "releasing lock using flock()", 5 );
flock($mutex, LOCK_UN);
flock( $mutex, LOCK_UN );
} else {
wp_cache_debug( "releasing lock using sem_release()", 5 );
sem_release($mutex);
wp_cache_debug( "releasing lock using sem_release() and sem_remove()", 5 );
@sem_release( $mutex );
if ( defined( "WPSC_REMOVE_SEMAPHORE" ) )
@sem_remove( $mutex );
}
}
......@@ -259,6 +267,12 @@ function wp_cache_ob_callback( $buffer ) {
} elseif ( $_SERVER["REQUEST_METHOD"] == 'POST' || !empty( $_POST ) || get_option( 'gzipcompression' ) ) {
wp_cache_debug( 'Not caching POST request.', 5 );
$cache_this_page = false;
} elseif ( $_SERVER["REQUEST_METHOD"] == 'PUT' ) {
wp_cache_debug( 'Not caching PUT request.', 5 );
$cache_this_page = false;
} elseif ( $_SERVER["REQUEST_METHOD"] == 'DELETE' ) {
wp_cache_debug( 'Not caching DELETE request.', 5 );
$cache_this_page = false;
} elseif ( $wp_cache_object_cache && !empty( $_GET ) ) {
wp_cache_debug( 'Not caching GET request while object cache storage enabled.', 5 );
$cache_this_page = false;
......@@ -388,7 +402,7 @@ function wp_cache_get_ob(&$buffer) {
$wp_cache_mfunc_enabled = 0;
$new_cache = true;
$wp_cache_meta = '';
$wp_cache_meta = array();
/* Mode paranoic, check for closing tags
* we avoid caching incomplete files */
......@@ -1122,21 +1136,19 @@ function wp_cache_post_id_gc( $siteurl, $post_id, $all = 'all' ) {
$permalink = trailingslashit( str_replace( get_option( 'home' ), '', get_permalink( $post_id ) ) );
$dir = get_current_url_supercache_dir( $post_id );
wp_cache_debug( "wp_cache_post_id_gc post_id: $post_id " . get_permalink( $post_id ) . " clearing cache in $dir.", 4 );
if ( $all == 'all' ) {
if ( $all ) {
prune_super_cache( $dir, true, true );
do_action( 'gc_cache', 'prune', $permalink );
@rmdir( $dir );
wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$supercache_home}page/." );
$supercache_home = get_supercache_dir();
prune_super_cache( $supercache_home . 'page/', true );
do_action( 'gc_cache', 'prune', 'page/' );
} else {
wp_cache_debug( "wp_cache_post_id_gc clearing cached index files in $dir.", 4 );
prune_super_cache( $dir, true, true );
do_action( 'gc_cache', 'prune', $permalink );
}
wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$dir}/page/.", 4 );
prune_super_cache( $dir . '/page/', true );
$supercache_home = get_supercache_dir();
wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$supercache_home}/page/.", 4 );
prune_super_cache( $supercache_home . '/page/', true );
do_action( 'gc_cache', 'prune', '/page/' );
}
function wp_cache_post_change( $post_id ) {
......@@ -1171,39 +1183,43 @@ function wp_cache_post_change( $post_id ) {
$all = true;
}
$all_backup = $all;
$all = apply_filters( 'wpsc_delete_related_pages_on_edit', $all ); // return 0 to disable deleting homepage and other pages.
if ( $all != $all_backup )
wp_cache_debug( 'wp_cache_post_change: $all changed by wpsc_delete_related_pages_on_edit filter: ' . intval( $all ) );
if ( $wp_cache_object_cache )
reset_oc_version();
$permalink = trailingslashit( str_replace( get_option( 'siteurl' ), '', get_permalink( $post_id ) ) );
if( $super_cache_enabled ) {
$dir = get_supercache_dir();
$siteurl = trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'https://', '', str_replace( 'http://', '', get_option( 'home' ) ) ) ) ) );
// make sure the front page has a rebuild file
wp_cache_post_id_gc( $siteurl, $post_id );
if ( $all == true ) {
wp_cache_debug( "Post change: supercache enabled: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4 );
$files_to_check = get_all_supercache_filenames( $dir );
foreach( $files_to_check as $cache_file ) {
wp_cache_debug( "Post change: deleting cache file: " . $dir . $cache_file, 4 );
prune_super_cache( $dir . $cache_file, true, true );
}
do_action( 'gc_cache', 'prune', 'homepage' );
} else {
wp_cache_debug( "wp_cache_post_change: not deleting all pages.", 4 );
// Delete supercache files whenever a post change event occurs, even if supercache is currently disabled.
$dir = get_supercache_dir();
$siteurl = trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'https://', '', str_replace( 'http://', '', get_option( 'home' ) ) ) ) ) );
// make sure the front page has a rebuild file
wp_cache_post_id_gc( $siteurl, $post_id, $all );
if ( $all == true ) {
wp_cache_debug( "Post change: supercache enabled: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4 );
$files_to_check = get_all_supercache_filenames( $dir );
foreach( $files_to_check as $cache_file ) {
wp_cache_debug( "Post change: deleting cache file: " . $dir . $cache_file, 4 );
prune_super_cache( $dir . $cache_file, true, true );
}
if( $all == true && get_option( 'show_on_front' ) == 'page' ) {
wp_cache_debug( "Post change: deleting page_on_front and page_for_posts pages.", 4 );
wp_cache_debug( "Post change: page_on_front " . get_option( 'page_on_front' ), 4 );
wp_cache_post_id_gc( $siteurl, get_option( 'page_on_front' ), 'single' );
$permalink = trailingslashit( str_replace( get_option( 'home' ), '', get_permalink( get_option( 'page_for_posts' ) ) ) );
$files_to_check = get_all_supercache_filenames( $dir . $permalink );
foreach( $files_to_check as $cache_file ) {
prune_super_cache( $dir . $permalink . $cache_file, true, true );
}
do_action( 'gc_cache', 'prune', $permalink );
} else {
wp_cache_debug( "wp_cache_post_change: not deleting front static page.", 4 );
do_action( 'gc_cache', 'prune', 'homepage' );
} else {