Skip to content

Commit

Permalink
WP Super Cache: fix the CDN function when caching is disabled by logg…
Browse files Browse the repository at this point in the history
…ed-in check (#37112)

* Remove links to non-existant website

* Remove DONOTCACHEPAGE check this early as it stopped CDN working

* Don't set $cache_enabled when DONOTCACHEPAGE is already set.

* changelog

* If cache disabled then set this constant

* Revert that DONOTCACHPAGE, cache_enabled checks happen before it

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/8897910545

Upstream-Ref: Automattic/jetpack@ca60e4c
  • Loading branch information
donnchawp authored and matticbot committed Apr 30, 2024
1 parent fb54c66 commit abf8e41
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This is an alpha version! The changes listed here are not final.
- Updated package dependencies.

### Fixed
- Super-cache: Fix the CDN functionality when cache is disabled
- WP Super Cache: do not define DONOTCACHEPAGE if it is already defined

## [1.12.0] - 2024-03-11
Expand Down
12 changes: 10 additions & 2 deletions ossdl-cdn.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/* Taken from OSSDL CDN off-linker, a plugin by W-Mark Kubacki (http://mark.ossdl.de/) and used with permission */
/* Taken from OSSDL CDN off-linker, a plugin by W-Mark Kubacki and used with permission */

if ( ! isset( $ossdlcdn ) ) {
$ossdlcdn = 1; // have to default to on for existing users.
Expand Down Expand Up @@ -374,7 +374,15 @@ function scossdl_off_options() {
<input type="hidden" name="action" value="update_ossdl_off" />
<p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'wp-super-cache' ); ?>" /></p>
</form></p>
<p><?php _e( 'CDN functionality provided by <a href="https://wordpress.org/plugins/ossdl-cdn-off-linker/">OSSDL CDN Off Linker</a> by <a href="http://mark.ossdl.de/">Mark Kubacki</a>', 'wp-super-cache' ); ?></p>
<p>
<?php
printf(
/* Translators: placeholder is a link to OSSDL CDN Off Linker plugin on WordPress.org */
esc_html__( 'CDN functionality provided by %s by Mark Kubacki', 'wp-super-cache' ),
'<a href="https://wordpress.org/plugins/ossdl-cdn-off-linker/">OSSDL CDN Off Linker</a>'
);
?>
</p>
</div> <!-- Close .wpsc-card -->
<?php
}
4 changes: 1 addition & 3 deletions wp-cache-phase1.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@

// from the secret shown on the Advanced settings page.
if ( isset( $_GET['donotcachepage'] ) && isset( $cache_page_secret ) && $_GET['donotcachepage'] == $cache_page_secret ) {
$cache_enabled = false;
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', 1 );
}
Expand Down Expand Up @@ -124,7 +123,6 @@
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', 1 );
}
$cache_enabled = false;
wp_cache_debug( 'Caching disabled because rejected cookie found.' );
return true;
}
Expand All @@ -145,7 +143,7 @@
// an init action wpsc plugins can hook on to.
do_cacheaction( 'cache_init' );

if ( ! $cache_enabled ) {
if ( ! $cache_enabled ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- set by configuration or cache_init action
return true;
}

Expand Down
5 changes: 0 additions & 5 deletions wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,6 @@ function wp_cache_postload() {
global $cache_enabled, $wp_super_cache_late_init;
global $wp_cache_request_uri;

if ( defined( 'DONOTCACHEPAGE' ) && DONOTCACHEPAGE ) {
wp_cache_debug( 'wp_cache_postload: DONOTCACHEPAGE defined. Not running.' );
return false;
}

if ( empty( $wp_cache_request_uri ) ) {
wp_cache_debug( 'wp_cache_postload: no request uri configured. Not running.' );
return false;
Expand Down

0 comments on commit abf8e41

Please sign in to comment.