ld( $key, $group = '' ) {
$has_old_data = false;
$key = $this->get_item_key( $key );
$path = $this->_cache_dir . DIRECTORY_SEPARATOR .
$this->_get_path( $key, $group );
$data = $this->_read( $path );
if ( $data != null )
return array( $data, $has_old_data );
$path_old = $path . '_old';
$too_old_time = time() - 30;
if ( $exists = file_exists( $path_old ) ) {
$file_time = @filemtime( $path_old );
if ( $file_time ) {
if ( $file_time > $too_old_time ) {
// return old data
$has_old_data = true;
return array( $this->_read( $path_old ), $has_old_data );
}
// use old enough time to cause recalculation on next call
@touch( $path_old, 1479904835 );
}
}
$has_old_data = $exists;
return array( null, $has_old_data );
}
/**
* Reads file
*
* @param string $path
* @return array
*/
private function _read( $path ) {
if ( !is_readable( $path ) )
return null;
// make sure reading from cache folder
// canonicalize to avoid unexpected variants
$base_path = realpath( $this->_cache_dir );
$path = realpath( $path );
if ( strlen( $base_path ) <= 0 ||
substr( $path, 0, strlen( $base_path ) ) != $base_path ) {
return null;
}
$fp = @fopen( $path, 'rb' );
if ( !$fp )
return null;
if ( $this->_locking )
@flock( $fp, LOCK_SH );
$var = '';
while ( !@feof( $fp ) )
$var .= @fread( $fp, 4096 );
@fclose( $fp );
if ( $this->_locking )
@flock( $fp, LOCK_UN );
$headers = array();
if ( substr( $path, -4 ) == '.xml' ) {
$headers['Content-type'] = 'text/xml';
}
return array(
'404' => false,
'headers' => $headers,
'time' => null,
'content' => $var
);
}
/**
* Deletes data
*
* @param string $key
* @param string $group Used to differentiate between groups of cache values
* @return boolean
*/
function delete( $key, $group = '' ) {
$key = $this->get_item_key( $key );
$path = $this->_cache_dir . DIRECTORY_SEPARATOR . $this->_get_path( $key, $group );
if ( !file_exists( $path ) )
return true;
$dir = dirname( $path );
if ( file_exists( $dir . DIRECTORY_SEPARATOR . '.htaccess' ) ) {
@unlink( $dir . DIRECTORY_SEPARATOR . '.htaccess' );
}
$old_entry_path = $path . '_old';
if ( ! @rename( $path, $old_entry_path ) ) {
// if we can delete old entry - do second attempt to store in old-entry file
if ( ! @unlink( $old_entry_path ) || ! @rename( $path, $old_entry_path ) ) {
return @unlink( $path );
}
}
@touch( $old_entry_path, 1479904835 );
return true;
}
/**
* Key to delete, deletes _old and primary if exists.
*
* @param unknown $key
* @return bool
*/
function hard_delete( $key, $group = '' ) {
$key = $this->get_item_key( $key );
$path = $this->_cache_dir . DIRECTORY_SEPARATOR . $this->_get_path( $key, $group );
$old_entry_path = $path . '_old';
@unlink( $old_entry_path );
if ( !file_exists( $path ) )
return true;
@unlink( $path );
return true;
}
/**
* Flushes all data
*
* @param string $group Used to differentiate between groups of cache values
* @return boolean
*/
function flush( $group = '' ) {
if ( $group == 'sitemaps' ) {
$config = Dispatcher::config();
$sitemap_regex = $config->get_string( 'pgcache.purge.sitemap_regex' );
$this->_flush_based_on_regex( $sitemap_regex );
} else {
$dir = $this->_flush_dir;
if ( !empty( $group ) ) {
$c = new Cache_File_Cleaner_Generic_HardDelete( array(
'cache_dir' => $this->_flush_dir .
DIRECTORY_SEPARATOR . $group,
'exclude' => $this->_exclude,
'clean_timelimit' => $this->_flush_timelimit
) );
} else {
$c = new Cache_File_Cleaner_Generic( array(
'cache_dir' => $this->_flush_dir,
'exclude' => $this->_exclude,
'clean_timelimit' => $this->_flush_timelimit
) );
}
$c->clean();
}
}
/**
* Returns cache file path by key
*
* @param string $key
* @return string
*/
function _get_path( $key, $group = '' ) {
return ( empty( $group ) ? '' : $group . DIRECTORY_SEPARATOR ) . $key;
}
function get_item_key( $key ) {
return $key;
}
/**
* Flush cache based on regex
*
* @param string $regex
*/
private function _flush_based_on_regex( $regex ) {
if ( Util_Environment::is_wpmu() && !Util_Environment::is_wpmu_subdomain() ) {
$domain = get_home_url();
$parsed = parse_url( $domain );
$host = $parsed['host'];
$path = isset( $parsed['path'] ) ? '/' . trim( $parsed['path'], '/' ) : '';
$flush_dir = W3TC_CACHE_PAGE_ENHANCED_DIR .
DIRECTORY_SEPARATOR . $host . $path;
} else
$flush_dir = W3TC_CACHE_PAGE_ENHANCED_DIR .
DIRECTORY_SEPARATOR . Util_Environment::host();
$dir = @opendir( $flush_dir );
if ( $dir ) {
while ( ( $entry = @readdir( $dir ) ) !== false ) {
if ( $entry == '.' || $entry == '..' ) {
continue;
}
if ( preg_match( '~' . $regex . '~', basename( $entry ) ) ) {
Util_File::rmdir( $flush_dir . DIRECTORY_SEPARATOR . $entry );
}
}
@closedir( $dir );
}
}
}
Fatal error: Uncaught Error: Class 'W3TC\Cache_File_Generic' not found in /var/www/html/bkr-lopesmachado.com.br/web/wp-content/plugins/w3-total-cache/Cache.php:46
Stack trace:
#0 /var/www/html/bkr-lopesmachado.com.br/web/wp-content/plugins/w3-total-cache/PgCache_ContentGrabber.php(940): W3TC\Cache::instance('file_generic', Array)
#1 /var/www/html/bkr-lopesmachado.com.br/web/wp-content/plugins/w3-total-cache/PgCache_ContentGrabber.php(269): W3TC\PgCache_ContentGrabber->_get_cache('*')
#2 /var/www/html/bkr-lopesmachado.com.br/web/wp-content/plugins/w3-total-cache/PgCache_ContentGrabber.php(217): W3TC\PgCache_ContentGrabber->_extract_cached_page(false)
#3 /var/www/html/bkr-lopesmachado.com.br/web/wp-content/advanced-cache.php(37): W3TC\PgCache_ContentGrabber->process()
#4 /var/www/html/bkr-lopesmachado.com.br/web/wp-settings.php(95): include('/var/www/html/b...')
#5 /var/www/html/bkr-lopesmachado.com.br/web/wp-config.php(107): require_once('/var/www/html/b...')
#6 /var/www/html/bkr-lopesmachado.com.br/web/wp-load.php(50): re in /var/www/html/bkr-lopesmachado.com.br/web/wp-content/plugins/w3-total-cache/Cache.php on line 46