Skip to content

Commit

Permalink
bump 20.10.07
Browse files Browse the repository at this point in the history
- Fixed Tweaks::misc() -> removed deprecated jetpack hook instagram_cache_oembed_api_response_body.
- Fixed Filesystem::validate_fatal_error_file() -> update timestamp.
- Added Filesystem::suspend_cache_file().
  • Loading branch information
nawawi committed Nov 25, 2020
1 parent af40c40 commit 8ef7f7a
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 106 deletions.
Binary file modified .wordpress.org/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress.org/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
= 20.10.07 (2020-11-26)

- Fixed Tweaks::misc() -> removed deprecated jetpack hook instagram_cache_oembed_api_response_body.
- Fixed Filesystem::validate_fatal_error_file() -> update timestamp.
- Added Filesystem::suspend_cache_file().

= 20.10.06 (2020-11-23)

- Fixed Filesystem::scanfiles() -> missing regex pattern for dump file.
Expand Down
4 changes: 2 additions & 2 deletions docket-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* @wordpress-plugin
* Plugin Name: Docket Cache
* Plugin URI: https://wordpress.org/plugins/docket-cache/
* Version: 20.10.06
* VerPrev: 20.10.05
* Version: 20.10.07
* VerPrev: 20.10.06
* Description: A persistent object cache stored as a plain PHP code, accelerates caching with OPcache backend.
* GitHub Plugin URI: https://github.com/nawawi/docket-cache
* Author: Nawawi Jamili
Expand Down
3 changes: 0 additions & 3 deletions includes/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -1227,9 +1227,6 @@ function () use ($req_key) {
*/
private function dc_init()
{
// handle error
$this->fs()->capture_fatal_error();

if ($this->cf()->is_dcint('MAXSIZE', $dcvalue)) {
if ($dcvalue >= 1000000) {
$this->cache_maxsize = $dcvalue;
Expand Down
2 changes: 1 addition & 1 deletion includes/object-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @wordpress-plugin
* Plugin Name: Docket Cache Drop-in
* Plugin URI: https://wordpress.org/plugins/docket-cache/
* Version: 20.10.06
* Version: 20.10.07
* Description: A persistent object cache stored as a plain PHP code, accelerates caching with OPcache backend.
* Author: Nawawi Jamili
* Author URI: https://docketcache.com
Expand Down
2 changes: 1 addition & 1 deletion includes/src/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

final class Crawler
{
private static $version = '20.10.06';
private static $version = '20.10.07';
public static $send_cookie = false;

private static function default_args($param = [])
Expand Down
2 changes: 1 addition & 1 deletion includes/src/CronAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private function run_wpcron($run_now = false)
try {
do_action_ref_array($hook, $v['args']);
++$run_event;
} catch (\Exception $e) {
} catch (\Throwable $e) {
$results['wpcron_error'][$hook] = $e->getMessage();
wp_clear_scheduled_hook($hook);
--$run_event;
Expand Down
36 changes: 28 additions & 8 deletions includes/src/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function validate_file($filename, &$error = '')
{
try {
$fileo = new \SplFileObject($filename, 'rb');
} catch (\Exception $e) {
} catch (\Throwable $e) {
$error = $e->getMessage();

return false;
Expand Down Expand Up @@ -167,7 +167,7 @@ public function export_var($data, &$error = '')
{
try {
$data = VarExporter::export($data);
} catch (\Exception $e) {
} catch (\Throwable $e) {
$error = $e->getMessage();
if (false !== strpos($error, 'Cannot export value of type "stdClass"')) {
$data = var_export($data, 1);
Expand Down Expand Up @@ -631,14 +631,26 @@ public function validate_fatal_error_file($file)
return;
}

$fm = time() - 3600; // 1h
if ($fm > @filemtime($file_fatal) && $this->validate_file($file)) {
@unlink($file_fatal);
$fm = time() - 300; // 5m
if ($fm > @filemtime($file_fatal)) {
if ($this->validate_file($file)) {
@unlink($file_fatal);

return;
return;
}

// update timestamp
@touch($file_fatal);
}
}

private function suspend_cache_file($file, $error)
{
$file_fatal = $this->get_fatal_error_filename($file);

return @file_put_contents($file_fatal, date('Y-m-d H:i:s T').PHP_EOL.$error, LOCK_EX);
}

public function capture_fatal_error()
{
register_shutdown_function(
Expand All @@ -652,7 +664,7 @@ function () {
$error['file'] = str_replace(ABSPATH, '/', $file_error);

@file_put_contents($file_error, '<?php return false;', LOCK_EX);
if (@file_put_contents($file_fatal, date('Y-m-d H:i:s T').PHP_EOL.$this->export_var($error), LOCK_EX)) {
if ($this->suspend_cache_file($file_fatal, $this->export_var($error))) {
if ('cli' !== \PHP_SAPI && !wp_doing_ajax()) {
echo '<script>document.body.innerHTML="";window.setTimeout(function() { window.location.assign(window.location.href); }, 750);</script>';
}
Expand Down Expand Up @@ -680,19 +692,27 @@ public function cache_get($file)
return false;
}

// handle error incase not throwable
$this->capture_fatal_error();

$data = [];

// include when we can read, try to avoid fatal error.
// LOCK_SH = shared lock
if (flock($handle, LOCK_SH)) {
try {
$data = @include $file;
} catch (\Exception $e) {
} catch (\Throwable $e) {
$error = $e->getMessage();

// cleanup
if (false !== strpos($error, 'not found') && @preg_match('@Class.*not found@', $error)) {
$this->unlink($file, false);
}

// delay
$this->suspend_cache_file($file, $error);

$this->log('err', 'internalproc-internalfunc', 'cache_get: '.$error);
$data = false;
}
Expand Down
40 changes: 2 additions & 38 deletions includes/src/Tweaks.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ function () {

// jetpack: enables object caching for the response sent by instagram when querying for instagram image html
// https://developer.jetpack.com/hooks/instagram_cache_oembed_api_response_body/
add_filter('instagram_cache_oembed_api_response_body', '__return_true');
// Removed in Jetpack 9.1.0
//add_filter('instagram_cache_oembed_api_response_body', '__return_true');

if (nwdcx_consfalse('TWEAKS_WPCOOKIE_DISABLED')) {
// wp: comment cookie lifetime, default to 30000000 second = 12 months
Expand Down Expand Up @@ -117,43 +118,6 @@ function () {

add_filter('the_generator', '__return_empty_string', PHP_INT_MAX);
add_filter('x_redirect_by', '__return_false', PHP_INT_MAX);

// only if has page caching
/*if (\defined('WP_CACHE') && WP_CACHE) {
add_action(
'after_setup_theme',
function () {
nwdcx_consdef('doing_buffer_headerjunk', true);
@ob_start(null, 700000);
},
-PHP_INT_MAX
);
add_action(
'wp_head',
function () {
if (nwdcx_construe('doing_buffer_headerjunk')) {
$content = @ob_get_clean();
if (empty($content)) {
return;
}
if (false !== strpos($content, 'gmpg.org/xfn/11')) {
$regexp = '@<link[^>]+href=(?:\'|")(https?:)?\/\/gmpg.org\/xfn\/11(?:\'|")(?:[^>]+)?>@';
$content = @preg_replace($regexp, '', $content);
}
if (false !== strpos($content, 'rel="pingback"')) {
$regexp = '@(<link.*?rel=("|\')pingback("|\').*?href=("|\')(.*?)("|\')(.*?)?\/?>|<link.*?href=("|\')(.*?)("|\').*?rel=("|\')pingback("|\')(.*?)?\/?>)@';
$content = @preg_replace($regexp, '', $content);
}
echo $content;
}
},
PHP_INT_MAX
);
}*/
}

public function pingback()
Expand Down
2 changes: 1 addition & 1 deletion includes/src/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function tail($filename, $limit = 100, $do_last = true, &$error = '')

try {
$fileo = new \SplFileObject($filename, 'rb');
} catch (\Exception $e) {
} catch (\Throwable $e) {
$error = $e->getMessage();

return $object;
Expand Down
4 changes: 2 additions & 2 deletions languages/docket-cache.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the same license as the Docket Cache plugin.
msgid ""
msgstr ""
"Project-Id-Version: Docket Cache 20.10.06\n"
"Project-Id-Version: Docket Cache 20.10.07\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/docket-cache\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2020-11-22T23:10:13+00:00\n"
"POT-Creation-Date: 2020-11-25T21:50:53+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.4.0\n"
"X-Domain: docket-cache\n"
Expand Down
61 changes: 12 additions & 49 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Donate link: https://www.patreon.com/bePatron?u=41796862
Requires at least: 5.4
Tested up to: 5.5
Requires PHP: 7.2.5
Stable tag: 20.10.06
Stable tag: 20.10.07
License: MIT
License URI: ./license.txt

Expand Down Expand Up @@ -73,11 +73,11 @@ Sponsored by:

Affiliates with:

- [Dreamhost](https://docketcache.com/wp-content/spx/dreamhost/?utm_source=dcwporg)
- [Bluehost](https://docketcache.com/wp-content/spx/bluehost/?utm_source=dcwporg)
- [Exabytes](https://docketcache.com/wp-content/spx/exabytes/?utm_source=dcwporg)
- [ServerFreak](https://docketcache.com/wp-content/spx/serverfreak/?utm_source=dcwporg)
- [Digitalocean](https://docketcache.com/wp-content/spx/digitalocean/?utm_source=dcwporg)
- [Dreamhost](https://mbsy.co/3cGLwM)
- [Bluehost](https://www.bluehost.com/track/docketcache/)
- [Exabytes](https://billing.exabytes.my/mypanel/aff.php?aff=8102792)
- [ServerFreak](https://secure.web-hosting.net.my/clients/aff.php?aff=4725)
- [Digitalocean](https://m.do.co/c/6c93db5b1ef6)
- [KiahStore](https://docketcache.com/wp-content/spx/kiahstore/?utm_source=dcwporg)

== Development ==
Expand Down Expand Up @@ -176,6 +176,12 @@ Yes, you can. It can boost more your WordPress performance since there is no net
Kindly do manually remove wp-content/object-cache.php and wp-content/cache/docket-cache if an error occurs during updates. Thanks.

== Changelog ==
= 20.10.07 =

- Fixed Tweaks::misc() -> removed deprecated jetpack hook instagram_cache_oembed_api_response_body.
- Fixed Filesystem::validate_fatal_error_file() -> update timestamp.
- Added Filesystem::suspend_cache_file().

= 20.10.06 =

- Fixed Filesystem::scanfiles() -> missing regex pattern for dump file.
Expand All @@ -185,49 +191,6 @@ Kindly do manually remove wp-content/object-cache.php and wp-content/cache/docke
- Added Garbage Collector -> action button output results.
- Added Filesystem::capture_fatal_error() -> attempt to fix any cache file error-prone.

= 20.10.05 =

- Fixed Litespeed Cache admin notice "Purged all caches successfully" still shown after dismiss.

= 20.10.04 =

- Improved CronAgent.
- Improved CLI.
- Improved disk I/O and CPU usage.
- Optimized WP Alloptions.

Thank you for using docket cache.

= 20.10.03 =

- Fixed nwdcx_optget() -> missing sql syntax.

Thanks to Mark Barnes (@mark8barnes) for reporting this issue.

= 20.10.02 =

- Fixed output buffering issue with page caching.

= 20.10.01 =

This is Major Release based on previous releases.

- Improved precaching.
- Improved cache stats.
- Improved garbage collector.
- Improved disk I/O and CPU usage.
- Added new constant DOCKET_CACHE_CONTENT_PATH.

Thank you for using docket cache.

= 20.09.07 =

Fix release.

- Fixed Deactivate WooCommerce Widget, prevent error notice _doing_it_wrong for the_widget.
- Fixed Precaching, always strip query string doing_wp_cron.
- Fixed nwdcx_network_multi function, replace with simple query to detect multinetwork condition.



Kindly refer to [changelog.txt](https://raw.githubusercontent.com/nawawi/docket-cache/master/changelog.txt) for previous changes.
Expand Down

0 comments on commit 8ef7f7a

Please sign in to comment.