Skip to content

Commit

Permalink
remove APC support
Browse files Browse the repository at this point in the history
APC is only supported up to PHP 5.5. As Cachify now requires PHP 5.6 or
later, there is no point in maintaining legacy APC support.

We already ignore unavailable backends silently with fallback to DB, so
just removing it does not make it worse here.
  • Loading branch information
stklcode committed Aug 6, 2024
1 parent f9eaee6 commit 3253b8f
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 331 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Cachify #
Smart, efficient cache solution for WordPress. Use DB, HDD, APC, Redis or Memcached for storing your blog pages. Make WordPress faster!
Smart, efficient cache solution for WordPress. Use DB, HDD, Redis or Memcached for storing your blog pages. Make WordPress faster!

## Description ##
*Cachify* optimizes your page loads by caching posts, pages and custom post types as static content. You can choose between caching via database, on the web server’s hard drive (HDD), Memcached (only on Nginx), Redis or — thanks to APC (Alternative PHP Cache) — directly in the web server’s system cache. Whenever a page or post is loaded, it can be pulled directly from the cache. The amount of database queries and PHP requests will dramatically decrease towards zero, depending on the caching method you chose.
*Cachify* optimizes your page loads by caching posts, pages and custom post types as static content. You can choose between caching via database, on the web server’s hard drive (HDD), Memcached (only on Nginx) or Redis. Whenever a page or post is loaded, it can be pulled directly from the cache. The amount of database queries and PHP requests will dramatically decrease towards zero, depending on the caching method you chose.

### Features ###
* Works with custom post types.
* Caching methods: DB, HDD, APC, Redis and Memcached.
* Caching methods: DB, HDD, Redis and Memcached.
* “Flush Cache” button in the WordPress toolbar.
* Ready for WordPress Multisite.
* Optional compression of HTML markup.
Expand Down Expand Up @@ -41,7 +41,6 @@ Smart, efficient cache solution for WordPress. Use DB, HDD, APC, Redis or Memcac
### Requirements ###
* PHP 5.6 or greater
* WordPress 4.7 or greater
* APC 3.1.4 or greater (optional)
* Memcached in Nginx (optional)
* Redis (optional, via the phpredis module)

Expand Down
62 changes: 4 additions & 58 deletions apc/proxy.php
Original file line number Diff line number Diff line change
@@ -1,63 +1,9 @@
<?php
/**
* Proxy for APC based caching.
* APC support was removed in Cachify 2.4.0
*
* @package Cachify
*/

if ( ! empty( $_COOKIE ) ) {
foreach ( $_COOKIE as $k => $v ) {
if ( preg_match( '/^(wp-postpass|wordpress_logged_in|comment_author)_/', $k ) ) {
$_cachify_logged_in = true;
break;
}
}
}

/**
* Determines if SSL is used.
* This file is just here to not break any remaining "auto_prepend_file" configurations.
* Will be removed with the next major update, so adjust your server's configuration, if you happen to read this notice.
*
* @see is_ssl() (wp-includes/load.php).
*
* @return bool True if SSL, otherwise false.
* @package Cachify
*/
function cachify_is_ssl() {
if ( isset( $_SERVER['HTTPS'] ) ) {
$https = filter_input( INPUT_SERVER, 'HTTPS', FILTER_SANITIZE_STRING );
if ( 'on' === strtolower( $https ) || '1' === $https ) {
return true;
}
} elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' === $_SERVER['SERVER_PORT'] ) ) {
return true;
}

return false;
}

if (
empty( $_cachify_logged_in )
&& extension_loaded( 'apc' )
&& ( strpos( filter_input( INPUT_SERVER, 'PHP_SELF', FILTER_SANITIZE_STRING ), '/wp-admin/' ) === false )
&& ( strpos( filter_input( INPUT_SERVER, 'HTTP_ACCEPT_ENCODING', FILTER_SANITIZE_STRING ), 'gzip' ) !== false )
) {
$cache = apc_fetch(
md5(
( cachify_is_ssl() ? 'https-' : '' ) .
filter_input( INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_STRING ) .
filter_input( INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL )
) .
'.cachify'
);
if ( $cache ) {
ini_set( 'zlib.output_compression', 'Off' );

header( 'Vary: Accept-Encoding' );
header( 'X-Powered-By: Cachify' );
header( 'Content-Encoding: gzip' );
header( 'Content-Length: ' . strlen( $cache ) );
header( 'Content-Type: text/html; charset=utf-8' );

echo $cache; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
exit;
}
}
4 changes: 2 additions & 2 deletions cachify.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: Cachify
* Description: Easy to use WordPress caching plugin. Serving static blog pages from database, disk, Memcached, Redis or APC.
* Description: Easy to use WordPress caching plugin. Serving static blog pages from database, disk, Memcached or Redis.
* Author: pluginkollektiv
* Author URI: https://pluginkollektiv.org
* Plugin URI: https://cachify.pluginkollektiv.org
Expand Down Expand Up @@ -91,7 +91,7 @@
* @param string $class_name the class name.
*/
function cachify_autoload( $class_name ) {
if ( in_array( $class_name, array( 'Cachify', 'Cachify_APC', 'Cachify_Backend', 'Cachify_CLI', 'Cachify_DB', 'Cachify_HDD', 'Cachify_MEMCACHED', 'Cachify_REDIS' ), true ) ) {
if ( in_array( $class_name, array( 'Cachify', 'Cachify_Backend', 'Cachify_CLI', 'Cachify_DB', 'Cachify_HDD', 'Cachify_MEMCACHED', 'Cachify_REDIS' ), true ) ) {
require_once sprintf(
'%s/inc/class-%s.php',
CACHIFY_DIR,
Expand Down
154 changes: 0 additions & 154 deletions inc/class-cachify-apc.php

This file was deleted.

27 changes: 4 additions & 23 deletions inc/class-cachify.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class Cachify {
* @since 2.0.9
*/
const METHOD_DB = 0;
const METHOD_APC = 1;
const METHOD_APC = 1; // No longer available.
const METHOD_HDD = 2;
const METHOD_MMC = 3;
const METHOD_REDIS = 4;
Expand Down Expand Up @@ -389,12 +389,8 @@ private static function _set_default_vars() {
/* Options */
self::$options = self::_get_options();

/* APC */
if ( self::METHOD_APC === self::$options['use_apc'] && Cachify_APC::is_available() ) {
self::$method = new Cachify_APC();

/* HDD */
} elseif ( self::METHOD_HDD === self::$options['use_apc'] && Cachify_HDD::is_available() ) {
/* HDD */
if ( self::METHOD_HDD === self::$options['use_apc'] && Cachify_HDD::is_available() ) {
self::$method = new Cachify_HDD();

/* MEMCACHED */
Expand Down Expand Up @@ -1499,9 +1495,6 @@ public static function flush_total_cache( $clear_all_methods = false ) {
/* DB */
Cachify_DB::clear_cache();

/* APC */
Cachify_APC::clear_cache();

/* HDD */
Cachify_HDD::clear_cache();

Expand Down Expand Up @@ -1706,17 +1699,11 @@ private static function _method_select() {
/* Defaults */
$methods = array(
self::METHOD_DB => esc_html__( 'Database', 'cachify' ),
self::METHOD_APC => esc_html__( 'APC', 'cachify' ),
self::METHOD_HDD => esc_html__( 'Hard disk', 'cachify' ),
self::METHOD_MMC => esc_html__( 'Memcached', 'cachify' ),
self::METHOD_REDIS => esc_html__( 'Redis', 'cachify' ),
);

/* APC */
if ( ! Cachify_APC::is_available() ) {
unset( $methods[1] );
}

/* Memcached? */
if ( ! Cachify_MEMCACHED::is_available() ) {
unset( $methods[3] );
Expand Down Expand Up @@ -1786,7 +1773,7 @@ public static function validate_options( $data ) {
self::flush_total_cache( true );

/* Notification */
if ( self::$options['use_apc'] !== $data['use_apc'] && $data['use_apc'] >= self::METHOD_APC && self::METHOD_REDIS != $data['use_apc'] ) {
if ( self::$options['use_apc'] !== $data['use_apc'] && $data['use_apc'] >= self::METHOD_HDD && self::METHOD_REDIS != $data['use_apc'] ) {
add_settings_error(
'cachify_method_tip',
'cachify_method_tip',
Expand Down Expand Up @@ -1883,12 +1870,6 @@ private static function _get_tabs( $options ) {
'name' => __( 'Setup', 'cachify' ),
'page' => 'setup/cachify.hdd.' . ( self::$is_nginx ? 'nginx' : 'htaccess' ) . '.php',
);
} elseif ( self::METHOD_APC === $options['use_apc'] ) {
/* Setup tab for APC */
$tabs['setup'] = array(
'name' => __( 'Setup', 'cachify' ),
'page' => 'setup/cachify.apc.' . ( self::$is_nginx ? 'nginx' : 'htaccess' ) . '.php',
);
} elseif ( self::METHOD_MMC === $options['use_apc'] && self::$is_nginx ) {
/* Setup tab for Memcached */
$tabs['setup'] = array(
Expand Down
23 changes: 0 additions & 23 deletions inc/setup/cachify.apc.htaccess.php

This file was deleted.

33 changes: 0 additions & 33 deletions inc/setup/cachify.apc.nginx.php

This file was deleted.

Loading

0 comments on commit 3253b8f

Please sign in to comment.