Version Description
- Added PhpRedis API support.
- Added redis-lua script support to purge complete cache very fast.
- Added composer.json support
- Fixed cache purging link in admin bar.
- Updated the initial settings to include the 'purge_method' #99 - by gagan0123
Download this release
Release Info
Developer | rahul286 |
Plugin | Nginx Helper |
Version | 1.9.3 |
Comparing to | |
See all releases |
Code changes from version 1.9.2 to 1.9.3
- admin/admin.php +1 -1
- admin/install.php +2 -0
- admin/lib/nginx-general.php +1 -5
- composer.json +20 -0
- composer.lock +200 -0
- includes/redis-delete.php +54 -28
- nginx-helper.php +4 -4
- readme.txt +16 -9
- redis-purger.php +3 -2
- tests/functional/src/purge-method-get-request-page-test.js +5 -4
- tests/functional/src/purge-method-unlink-files-page-test.js +5 -4
admin/admin.php
CHANGED
@@ -118,7 +118,7 @@ namespace rtCamp\WP\Nginx {
|
|
118 |
if ( !current_user_can( 'manage_options' ) ) {
|
119 |
return;
|
120 |
}
|
121 |
-
$purge_url =
|
122 |
$nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' );
|
123 |
$admin_bar->add_menu( array( 'id' => 'nginx-helper-purge-all', 'title' => __( 'Purge Cache', 'nginx-helper' ), 'href' => $nonced_url, 'meta' => array( 'title' => __( 'Purge Cache', 'nginx-helper' ), ), ) );
|
124 |
}
|
118 |
if ( !current_user_can( 'manage_options' ) ) {
|
119 |
return;
|
120 |
}
|
121 |
+
$purge_url = add_query_arg( array( 'nginx_helper_action' => 'purge', 'nginx_helper_urls' => 'all' ) );
|
122 |
$nonced_url = wp_nonce_url( $purge_url, 'nginx_helper-purge_all' );
|
123 |
$admin_bar->add_menu( array( 'id' => 'nginx-helper-purge-all', 'title' => __( 'Purge Cache', 'nginx-helper' ), 'href' => $nonced_url, 'meta' => array( 'title' => __( 'Purge Cache', 'nginx-helper' ), ), ) );
|
124 |
}
|
admin/install.php
CHANGED
@@ -93,6 +93,8 @@ namespace rtCamp\WP\Nginx {
|
|
93 |
$rt_wp_nginx_helper_get_options[ 'purge_page_on_new_comment' ] = 1;
|
94 |
$rt_wp_nginx_helper_get_options[ 'purge_page_on_deleted_comment' ] = 1;
|
95 |
|
|
|
|
|
96 |
return $rt_wp_nginx_helper_get_options;
|
97 |
}
|
98 |
}
|
93 |
$rt_wp_nginx_helper_get_options[ 'purge_page_on_new_comment' ] = 1;
|
94 |
$rt_wp_nginx_helper_get_options[ 'purge_page_on_deleted_comment' ] = 1;
|
95 |
|
96 |
+
$rt_wp_nginx_helper_get_options[ 'purge_method' ] = 'get_request';
|
97 |
+
|
98 |
return $rt_wp_nginx_helper_get_options;
|
99 |
}
|
100 |
}
|
admin/lib/nginx-general.php
CHANGED
@@ -386,11 +386,7 @@ namespace rtCamp\WP\Nginx {
|
|
386 |
$log = fopen( $path . 'nginx.log', 'w' );
|
387 |
fclose( $log );
|
388 |
}
|
389 |
-
|
390 |
-
$rt_wp_nginx_purger->log( "+++++++++" );
|
391 |
-
$rt_wp_nginx_purger->log( "+Log Test" );
|
392 |
-
$rt_wp_nginx_purger->log( "+++++++++" );
|
393 |
-
}
|
394 |
if ( !is_writable( $path . 'nginx.log' ) ) {
|
395 |
?>
|
396 |
<span class="error fade" style="display : block"><p><?php printf( __( 'Can\'t write on log file.<br /><br />Check you have write permission on <strong>%s</strong>', 'nginx-helper' ), $rt_wp_nginx_helper->functional_asset_path() . 'nginx.log' ); ?></p></span><?php }
|
386 |
$log = fopen( $path . 'nginx.log', 'w' );
|
387 |
fclose( $log );
|
388 |
}
|
389 |
+
|
|
|
|
|
|
|
|
|
390 |
if ( !is_writable( $path . 'nginx.log' ) ) {
|
391 |
?>
|
392 |
<span class="error fade" style="display : block"><p><?php printf( __( 'Can\'t write on log file.<br /><br />Check you have write permission on <strong>%s</strong>', 'nginx-helper' ), $rt_wp_nginx_helper->functional_asset_path() . 'nginx.log' ); ?></p></span><?php }
|
composer.json
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "rtcamp/nginx-helper",
|
3 |
+
"description": "Cleans nginx's fastcgi/proxy cache or redis-cahce whenever a post is edited/published. Also does few more things.",
|
4 |
+
"keywords": ["wordpress", "plugin", "nginx", "nginx-helper", "fastcgi", "redis-cahce", "redis", "cache"],
|
5 |
+
"homepage": "https://rtcamp.com/nginx-helper/",
|
6 |
+
"license": "GPLv2",
|
7 |
+
"authors": [{
|
8 |
+
"name": "rtCamp",
|
9 |
+
"email": "admin@rtcamp.com",
|
10 |
+
"homepage": "https://rtcamp.com"
|
11 |
+
}],
|
12 |
+
"type": "wordpress-plugin",
|
13 |
+
"require": {
|
14 |
+
"php": ">=5.3.2",
|
15 |
+
"composer/installers": "v1.0.6"
|
16 |
+
},
|
17 |
+
"require-dev": {
|
18 |
+
"wpreadme2markdown/wpreadme2markdown": "*"
|
19 |
+
}
|
20 |
+
}
|
composer.lock
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_readme": [
|
3 |
+
"This file locks the dependencies of your project to a known state",
|
4 |
+
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
5 |
+
"This file is @generated automatically"
|
6 |
+
],
|
7 |
+
"hash": "f8ee8d46fadaee8c9cc194ef126e7404",
|
8 |
+
"packages": [
|
9 |
+
{
|
10 |
+
"name": "composer/installers",
|
11 |
+
"version": "v1.0.6",
|
12 |
+
"source": {
|
13 |
+
"type": "git",
|
14 |
+
"url": "https://github.com/composer/installers.git",
|
15 |
+
"reference": "b3bd071ea114a57212c75aa6a2eef5cfe0cc798f"
|
16 |
+
},
|
17 |
+
"dist": {
|
18 |
+
"type": "zip",
|
19 |
+
"url": "https://api.github.com/repos/composer/installers/zipball/b3bd071ea114a57212c75aa6a2eef5cfe0cc798f",
|
20 |
+
"reference": "b3bd071ea114a57212c75aa6a2eef5cfe0cc798f",
|
21 |
+
"shasum": ""
|
22 |
+
},
|
23 |
+
"replace": {
|
24 |
+
"shama/baton": "*"
|
25 |
+
},
|
26 |
+
"require-dev": {
|
27 |
+
"composer/composer": "1.0.*@dev",
|
28 |
+
"phpunit/phpunit": "3.7.*"
|
29 |
+
},
|
30 |
+
"type": "composer-installer",
|
31 |
+
"extra": {
|
32 |
+
"class": "Composer\\Installers\\Installer",
|
33 |
+
"branch-alias": {
|
34 |
+
"dev-master": "1.0-dev"
|
35 |
+
}
|
36 |
+
},
|
37 |
+
"autoload": {
|
38 |
+
"psr-0": {
|
39 |
+
"Composer\\Installers\\": "src/"
|
40 |
+
}
|
41 |
+
},
|
42 |
+
"notification-url": "https://packagist.org/downloads/",
|
43 |
+
"license": [
|
44 |
+
"MIT"
|
45 |
+
],
|
46 |
+
"authors": [
|
47 |
+
{
|
48 |
+
"name": "Kyle Robinson Young",
|
49 |
+
"email": "kyle@dontkry.com",
|
50 |
+
"homepage": "https://github.com/shama",
|
51 |
+
"role": "Developer"
|
52 |
+
}
|
53 |
+
],
|
54 |
+
"description": "A multi-framework Composer library installer",
|
55 |
+
"homepage": "http://composer.github.com/installers/",
|
56 |
+
"keywords": [
|
57 |
+
"TYPO3 CMS",
|
58 |
+
"TYPO3 Flow",
|
59 |
+
"TYPO3 Neos",
|
60 |
+
"agl",
|
61 |
+
"cakephp",
|
62 |
+
"codeigniter",
|
63 |
+
"drupal",
|
64 |
+
"fuelphp",
|
65 |
+
"installer",
|
66 |
+
"joomla",
|
67 |
+
"kohana",
|
68 |
+
"laravel",
|
69 |
+
"li3",
|
70 |
+
"lithium",
|
71 |
+
"mako",
|
72 |
+
"modulework",
|
73 |
+
"phpbb",
|
74 |
+
"ppi",
|
75 |
+
"silverstripe",
|
76 |
+
"symfony",
|
77 |
+
"wordpress",
|
78 |
+
"zend"
|
79 |
+
],
|
80 |
+
"time": "2013-08-20 04:37:09"
|
81 |
+
}
|
82 |
+
],
|
83 |
+
"packages-dev": [
|
84 |
+
{
|
85 |
+
"name": "symfony/console",
|
86 |
+
"version": "v2.7.1",
|
87 |
+
"source": {
|
88 |
+
"type": "git",
|
89 |
+
"url": "https://github.com/symfony/Console.git",
|
90 |
+
"reference": "564398bc1f33faf92fc2ec86859983d30eb81806"
|
91 |
+
},
|
92 |
+
"dist": {
|
93 |
+
"type": "zip",
|
94 |
+
"url": "https://api.github.com/repos/symfony/Console/zipball/564398bc1f33faf92fc2ec86859983d30eb81806",
|
95 |
+
"reference": "564398bc1f33faf92fc2ec86859983d30eb81806",
|
96 |
+
"shasum": ""
|
97 |
+
},
|
98 |
+
"require": {
|
99 |
+
"php": ">=5.3.9"
|
100 |
+
},
|
101 |
+
"require-dev": {
|
102 |
+
"psr/log": "~1.0",
|
103 |
+
"symfony/event-dispatcher": "~2.1",
|
104 |
+
"symfony/phpunit-bridge": "~2.7",
|
105 |
+
"symfony/process": "~2.1"
|
106 |
+
},
|
107 |
+
"suggest": {
|
108 |
+
"psr/log": "For using the console logger",
|
109 |
+
"symfony/event-dispatcher": "",
|
110 |
+
"symfony/process": ""
|
111 |
+
},
|
112 |
+
"type": "library",
|
113 |
+
"extra": {
|
114 |
+
"branch-alias": {
|
115 |
+
"dev-master": "2.7-dev"
|
116 |
+
}
|
117 |
+
},
|
118 |
+
"autoload": {
|
119 |
+
"psr-4": {
|
120 |
+
"Symfony\\Component\\Console\\": ""
|
121 |
+
}
|
122 |
+
},
|
123 |
+
"notification-url": "https://packagist.org/downloads/",
|
124 |
+
"license": [
|
125 |
+
"MIT"
|
126 |
+
],
|
127 |
+
"authors": [
|
128 |
+
{
|
129 |
+
"name": "Fabien Potencier",
|
130 |
+
"email": "fabien@symfony.com"
|
131 |
+
},
|
132 |
+
{
|
133 |
+
"name": "Symfony Community",
|
134 |
+
"homepage": "https://symfony.com/contributors"
|
135 |
+
}
|
136 |
+
],
|
137 |
+
"description": "Symfony Console Component",
|
138 |
+
"homepage": "https://symfony.com",
|
139 |
+
"time": "2015-06-10 15:30:22"
|
140 |
+
},
|
141 |
+
{
|
142 |
+
"name": "wpreadme2markdown/wpreadme2markdown",
|
143 |
+
"version": "2.0.0",
|
144 |
+
"source": {
|
145 |
+
"type": "git",
|
146 |
+
"url": "https://github.com/benbalter/WP-Readme-to-Github-Markdown.git",
|
147 |
+
"reference": "dceae108111232949affc9107c98276c6fa6c98f"
|
148 |
+
},
|
149 |
+
"dist": {
|
150 |
+
"type": "zip",
|
151 |
+
"url": "https://api.github.com/repos/benbalter/WP-Readme-to-Github-Markdown/zipball/dceae108111232949affc9107c98276c6fa6c98f",
|
152 |
+
"reference": "dceae108111232949affc9107c98276c6fa6c98f",
|
153 |
+
"shasum": ""
|
154 |
+
},
|
155 |
+
"require": {
|
156 |
+
"php": ">= 5.3.3",
|
157 |
+
"symfony/console": "~2.4"
|
158 |
+
},
|
159 |
+
"bin": [
|
160 |
+
"bin/wp2md"
|
161 |
+
],
|
162 |
+
"type": "library",
|
163 |
+
"autoload": {
|
164 |
+
"psr-4": {
|
165 |
+
"WPReadme2Markdown\\": "src/"
|
166 |
+
}
|
167 |
+
},
|
168 |
+
"notification-url": "https://packagist.org/downloads/",
|
169 |
+
"license": [
|
170 |
+
"MIT"
|
171 |
+
],
|
172 |
+
"authors": [
|
173 |
+
{
|
174 |
+
"name": "Christian Archer",
|
175 |
+
"email": "chrstnarchr@aol.com"
|
176 |
+
},
|
177 |
+
{
|
178 |
+
"name": "Benjamin J. Balter"
|
179 |
+
}
|
180 |
+
],
|
181 |
+
"description": "Convert WordPress Plugin readme.txt to Markdown",
|
182 |
+
"keywords": [
|
183 |
+
"converter",
|
184 |
+
"markdown",
|
185 |
+
"readme",
|
186 |
+
"wordpress"
|
187 |
+
],
|
188 |
+
"time": "2014-05-28 21:28:31"
|
189 |
+
}
|
190 |
+
],
|
191 |
+
"aliases": [],
|
192 |
+
"minimum-stability": "stable",
|
193 |
+
"stability-flags": [],
|
194 |
+
"prefer-stable": false,
|
195 |
+
"prefer-lowest": false,
|
196 |
+
"platform": {
|
197 |
+
"php": ">=5.3.2"
|
198 |
+
},
|
199 |
+
"platform-dev": []
|
200 |
+
}
|
includes/redis-delete.php
CHANGED
@@ -2,13 +2,36 @@
|
|
2 |
|
3 |
//TODO:: phpRedis based implementation https://github.com/phpredis/phpredis#eval
|
4 |
//include predis (php implementation for redis)
|
5 |
-
require_once 'predis.php';
|
6 |
-
Predis\Autoloader::register();
|
7 |
|
8 |
-
global $myredis, $rt_wp_nginx_helper;
|
9 |
|
10 |
$host = $rt_wp_nginx_helper->options['redis_hostname'];
|
11 |
$port = $rt_wp_nginx_helper->options['redis_port'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
//Lua Script
|
14 |
$lua = <<<LUA
|
@@ -21,31 +44,25 @@ end
|
|
21 |
return k
|
22 |
LUA;
|
23 |
|
24 |
-
//redis server parameter
|
25 |
-
$myredis = new Predis\Client( [
|
26 |
-
'host' => $host,
|
27 |
-
'port' => $port,
|
28 |
-
] );
|
29 |
-
|
30 |
-
//connect
|
31 |
-
try {
|
32 |
-
$myredis->connect();
|
33 |
-
} catch ( Exception $e ) {
|
34 |
-
|
35 |
-
}
|
36 |
-
|
37 |
-
|
38 |
/*
|
39 |
Delete multiple single keys without wildcard using redis pipeline feature to speed up things
|
40 |
*/
|
41 |
|
42 |
function delete_multi_keys( $key )
|
43 |
{
|
44 |
-
global $myredis;
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
50 |
|
51 |
/*
|
@@ -69,9 +86,14 @@ function flush_entire_db()
|
|
69 |
|
70 |
function delete_single_key( $key )
|
71 |
{
|
72 |
-
global $myredis;
|
|
|
73 |
if ( !empty( $myredis ) ) {
|
74 |
-
|
|
|
|
|
|
|
|
|
75 |
} else {
|
76 |
return false;
|
77 |
}
|
@@ -84,7 +106,7 @@ function delete_single_key( $key )
|
|
84 |
|
85 |
function delete_keys_by_wildcard( $pattern )
|
86 |
{
|
87 |
-
global $myredis, $lua;
|
88 |
/*
|
89 |
Lua Script block to delete multiple keys using wildcard
|
90 |
Script will return count i.e. number of keys deleted
|
@@ -94,9 +116,13 @@ function delete_keys_by_wildcard( $pattern )
|
|
94 |
/*
|
95 |
Call redis eval and return value from lua script
|
96 |
*/
|
97 |
-
if ( !empty( $myredis ) ) {
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
100 |
return false;
|
101 |
}
|
102 |
}
|
2 |
|
3 |
//TODO:: phpRedis based implementation https://github.com/phpredis/phpredis#eval
|
4 |
//include predis (php implementation for redis)
|
|
|
|
|
5 |
|
6 |
+
global $myredis, $rt_wp_nginx_helper, $redis_api, $lua;
|
7 |
|
8 |
$host = $rt_wp_nginx_helper->options['redis_hostname'];
|
9 |
$port = $rt_wp_nginx_helper->options['redis_port'];
|
10 |
+
$redis_api = '';
|
11 |
+
|
12 |
+
if ( class_exists( 'Redis' ) ) { // Use PHP5-Redis if installed.
|
13 |
+
try {
|
14 |
+
$myredis = new Redis();
|
15 |
+
$myredis->connect( $host, $port );
|
16 |
+
$redis_api = 'php-redis';
|
17 |
+
} catch ( Exception $e ) {}
|
18 |
+
} else {
|
19 |
+
if( ! class_exists( 'Predis\Autoloader' ) ) {
|
20 |
+
require_once 'predis.php';
|
21 |
+
}
|
22 |
+
Predis\Autoloader::register();
|
23 |
+
|
24 |
+
//redis server parameter
|
25 |
+
$myredis = new Predis\Client( [
|
26 |
+
'host' => $host,
|
27 |
+
'port' => $port,
|
28 |
+
] );
|
29 |
+
//connect
|
30 |
+
try {
|
31 |
+
$myredis->connect();
|
32 |
+
$redis_api = 'predis';
|
33 |
+
} catch ( Exception $e ) {}
|
34 |
+
}
|
35 |
|
36 |
//Lua Script
|
37 |
$lua = <<<LUA
|
44 |
return k
|
45 |
LUA;
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
/*
|
48 |
Delete multiple single keys without wildcard using redis pipeline feature to speed up things
|
49 |
*/
|
50 |
|
51 |
function delete_multi_keys( $key )
|
52 |
{
|
53 |
+
global $myredis, $redis_api;
|
54 |
+
if ( !empty( $myredis ) ) {
|
55 |
+
$matching_keys = $myredis->keys( $key );
|
56 |
+
if( $redis_api == 'predis') {
|
57 |
+
foreach ( $matching_keys as $key => $value ) {
|
58 |
+
$myredis->executeRaw( ['DEL', $value ] );
|
59 |
+
}
|
60 |
+
} else if( $redis_api == 'php-redis') {
|
61 |
+
return $myredis->del( $matching_keys );
|
62 |
+
}
|
63 |
+
} else {
|
64 |
+
return false;
|
65 |
+
}
|
66 |
}
|
67 |
|
68 |
/*
|
86 |
|
87 |
function delete_single_key( $key )
|
88 |
{
|
89 |
+
global $myredis, $redis_api;
|
90 |
+
|
91 |
if ( !empty( $myredis ) ) {
|
92 |
+
if( $redis_api == 'predis') {
|
93 |
+
return $myredis->executeRaw( ['DEL', $key ] );
|
94 |
+
} else if( $redis_api == 'php-redis') {
|
95 |
+
return $myredis->del( $key );
|
96 |
+
}
|
97 |
} else {
|
98 |
return false;
|
99 |
}
|
106 |
|
107 |
function delete_keys_by_wildcard( $pattern )
|
108 |
{
|
109 |
+
global $myredis, $lua, $redis_api;
|
110 |
/*
|
111 |
Lua Script block to delete multiple keys using wildcard
|
112 |
Script will return count i.e. number of keys deleted
|
116 |
/*
|
117 |
Call redis eval and return value from lua script
|
118 |
*/
|
119 |
+
if ( ! empty( $myredis ) ) {
|
120 |
+
if( $redis_api == 'predis') {
|
121 |
+
return $myredis->eval( $lua, 1, $pattern );
|
122 |
+
} else if( $redis_api == 'php-redis') {
|
123 |
+
return $myredis->eval( $lua, array( $pattern ), 1 );
|
124 |
+
}
|
125 |
+
} else {
|
126 |
return false;
|
127 |
}
|
128 |
}
|
nginx-helper.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/*
|
3 |
Plugin Name: Nginx Helper
|
4 |
Plugin URI: https://rtcamp.com/nginx-helper/
|
5 |
-
Description: Cleans nginx's fastcgi/proxy cache whenever a post is edited/published. Also does few more things.
|
6 |
-
Version: 1.9.
|
7 |
Author: rtCamp
|
8 |
Author URI: https://rtcamp.com
|
9 |
Text Domain: nginx-helper
|
@@ -128,11 +128,11 @@ namespace rtCamp\WP\Nginx {
|
|
128 |
global $blog_id, $rt_wp_nginx_purger;
|
129 |
$skip_status = array( 'auto-draft', 'draft', 'inherit', 'trash', 'pending' );
|
130 |
$purge_status = array( 'publish', 'future' );
|
131 |
-
|
132 |
if ( !$this->options['enable_purge'] || in_array( $old_status, $skip_status ) ) {
|
133 |
return;
|
134 |
}
|
135 |
-
|
136 |
if( in_array( $old_status, $purge_status ) || in_array( $new_status, $purge_status ) ) {
|
137 |
$rt_wp_nginx_purger->log( "Purge post on transition post STATUS from " . $old_status . " to " . $new_status );
|
138 |
$rt_wp_nginx_purger->purgePost( $post->ID );
|
2 |
/*
|
3 |
Plugin Name: Nginx Helper
|
4 |
Plugin URI: https://rtcamp.com/nginx-helper/
|
5 |
+
Description: Cleans nginx's fastcgi/proxy cache or redis-cahce whenever a post is edited/published. Also does few more things.
|
6 |
+
Version: 1.9.3
|
7 |
Author: rtCamp
|
8 |
Author URI: https://rtcamp.com
|
9 |
Text Domain: nginx-helper
|
128 |
global $blog_id, $rt_wp_nginx_purger;
|
129 |
$skip_status = array( 'auto-draft', 'draft', 'inherit', 'trash', 'pending' );
|
130 |
$purge_status = array( 'publish', 'future' );
|
131 |
+
|
132 |
if ( !$this->options['enable_purge'] || in_array( $old_status, $skip_status ) ) {
|
133 |
return;
|
134 |
}
|
135 |
+
|
136 |
if( in_array( $old_status, $purge_status ) || in_array( $new_status, $purge_status ) ) {
|
137 |
$rt_wp_nginx_purger->log( "Purge post on transition post STATUS from " . $old_status . " to " . $new_status );
|
138 |
$rt_wp_nginx_purger->purgePost( $post->ID );
|
readme.txt
CHANGED
@@ -1,21 +1,19 @@
|
|
1 |
=== Nginx Helper ===
|
2 |
-
Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd,
|
3 |
-
Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, rewrite, permalinks
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.2.2
|
6 |
-
Stable tag: 1.9.
|
7 |
-
later (of-.1course)
|
8 |
-
Fix purging for custom post types
|
9 |
-
|
10 |
License: GPLv2 or later (of-course)
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
Donate Link: http://rtcamp.com/donate/
|
13 |
|
14 |
-
Cleans nginx's fastcgi/proxy cache whenever a post is edited/published. Also does
|
15 |
|
16 |
== Description ==
|
17 |
|
18 |
1. Removes `index.php` from permalinks when using WordPress with nginx.
|
|
|
19 |
1. Adds support for nginx fastcgi_cache_purge & proxy_cache_purge directive from [module](https://github.com/FRiCKLE/ngx_cache_purge "ngx_cache_purge module"). Provides settings so you can customize purging rules.
|
20 |
1. Adds support for nginx `map{..}` on a WordPress-multisite network installation. Using it, Nginx can serve PHP file uploads even if PHP/MySQL crashes. Please check the tutorial list below for related Nginx configurations.
|
21 |
|
@@ -116,6 +114,14 @@ Please post your problem in [our free support forum](http://community.rtcamp.com
|
|
116 |
|
117 |
== Changelog ==
|
118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
= 1.9.2 =
|
120 |
Fix purging for Redis cache and FastCGI cache
|
121 |
|
@@ -305,5 +311,6 @@ Fix url escaping [#82](https://github.com/rtCamp/nginx-helper/pull/82) - by
|
|
305 |
|
306 |
== Upgrade Notice ==
|
307 |
|
308 |
-
= 1.9 =
|
309 |
-
Added
|
|
1 |
=== Nginx Helper ===
|
2 |
+
Contributors: rtcamp, rahul286, saurabhshukla, manishsongirkar36, faishal, desaiuditd, darren-slatten, jk3us, daankortenbach, telofy, pjv, llonchj, jinnko, weskoop, bcole808, gungeekatx, rohanveer, chandrapatel, gagan0123
|
3 |
+
Tags: nginx, cache, purge, nginx map, nginx cache, maps, fastcgi, proxy, redis, redis-cache, rewrite, permalinks
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.2.2
|
6 |
+
Stable tag: 1.9.3
|
|
|
|
|
|
|
7 |
License: GPLv2 or later (of-course)
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
Donate Link: http://rtcamp.com/donate/
|
10 |
|
11 |
+
Cleans nginx's fastcgi/proxy cache or redis-cahce whenever a post is edited/published. Also does few more things.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
1. Removes `index.php` from permalinks when using WordPress with nginx.
|
16 |
+
1. Adds support for purging redis-cache when used as full-page cache created using [nginx-srcache-module](https://github.com/openresty/srcache-nginx-module#caching-with-redis)
|
17 |
1. Adds support for nginx fastcgi_cache_purge & proxy_cache_purge directive from [module](https://github.com/FRiCKLE/ngx_cache_purge "ngx_cache_purge module"). Provides settings so you can customize purging rules.
|
18 |
1. Adds support for nginx `map{..}` on a WordPress-multisite network installation. Using it, Nginx can serve PHP file uploads even if PHP/MySQL crashes. Please check the tutorial list below for related Nginx configurations.
|
19 |
|
114 |
|
115 |
== Changelog ==
|
116 |
|
117 |
+
= 1.9.3 =
|
118 |
+
* Added PhpRedis API support.
|
119 |
+
* Added redis-lua script support to purge complete cache very fast.
|
120 |
+
* Added composer.json support
|
121 |
+
* Fixed cache purging link in admin bar.
|
122 |
+
* Updated the initial settings to include the 'purge_method' [#99](https://github.com/rtCamp/nginx-helper/pull/99) - by
|
123 |
+
[gagan0123](https://github.com/gagan0123)
|
124 |
+
|
125 |
= 1.9.2 =
|
126 |
Fix purging for Redis cache and FastCGI cache
|
127 |
|
311 |
|
312 |
== Upgrade Notice ==
|
313 |
|
314 |
+
= 1.9.3 =
|
315 |
+
* Added PhpRedis API support.
|
316 |
+
* Fixed cache purging link in admin bar.
|
redis-purger.php
CHANGED
@@ -662,8 +662,9 @@ namespace rtCamp\WP\Nginx {
|
|
662 |
$this->log( "* * * * *" );
|
663 |
$this->log( "* Purged Everything!" );
|
664 |
$this->log( "* * * * *" );
|
665 |
-
delete_multi_keys("*");
|
666 |
-
|
|
|
667 |
|
668 |
}
|
669 |
|
662 |
$this->log( "* * * * *" );
|
663 |
$this->log( "* Purged Everything!" );
|
664 |
$this->log( "* * * * *" );
|
665 |
+
//delete_multi_keys("*");
|
666 |
+
delete_keys_by_wildcard("*");
|
667 |
+
}
|
668 |
|
669 |
}
|
670 |
|
tests/functional/src/purge-method-get-request-page-test.js
CHANGED
@@ -53,13 +53,14 @@ module.exports = {
|
|
53 |
.wplogin(data.URLS.LOGIN, data.TESTADMINUSERNAME, data.TESTADMINPASSWORD)
|
54 |
.url(data.URLS.LOGIN + urlp)
|
55 |
.click('.post-edit-link')
|
56 |
-
|
57 |
-
.
|
58 |
-
.setValue('textarea[id="content"]', "test page content updated")
|
59 |
.click('#publish')
|
|
|
60 |
.wplogout()
|
61 |
.url(data.URLS.LOGIN + urlp)
|
62 |
-
.
|
|
|
63 |
},
|
64 |
|
65 |
'Step four : Page comment check ': function(browser) {
|
53 |
.wplogin(data.URLS.LOGIN, data.TESTADMINUSERNAME, data.TESTADMINPASSWORD)
|
54 |
.url(data.URLS.LOGIN + urlp)
|
55 |
.click('.post-edit-link')
|
56 |
+
.clearValue('#title')
|
57 |
+
.setValue('#title', "test page title updated")
|
|
|
58 |
.click('#publish')
|
59 |
+
.pause(2000)
|
60 |
.wplogout()
|
61 |
.url(data.URLS.LOGIN + urlp)
|
62 |
+
.verify.containsText(".entry-title", "test page title updated")
|
63 |
+
.verify.containsText(".site-main", "test page created for testing")
|
64 |
},
|
65 |
|
66 |
'Step four : Page comment check ': function(browser) {
|
tests/functional/src/purge-method-unlink-files-page-test.js
CHANGED
@@ -53,13 +53,14 @@ module.exports = {
|
|
53 |
.wplogin(data.URLS.LOGIN, data.TESTADMINUSERNAME, data.TESTADMINPASSWORD)
|
54 |
.url(data.URLS.LOGIN + urlp)
|
55 |
.click('.post-edit-link')
|
56 |
-
|
57 |
-
.
|
58 |
-
.setValue('textarea[id="content"]', "test page content updated")
|
59 |
.click('#publish')
|
|
|
60 |
.wplogout()
|
61 |
.url(data.URLS.LOGIN + urlp)
|
62 |
-
.
|
|
|
63 |
},
|
64 |
|
65 |
'Step four : Page comment check ': function(browser) {
|
53 |
.wplogin(data.URLS.LOGIN, data.TESTADMINUSERNAME, data.TESTADMINPASSWORD)
|
54 |
.url(data.URLS.LOGIN + urlp)
|
55 |
.click('.post-edit-link')
|
56 |
+
.clearValue('#title')
|
57 |
+
.setValue('#title', "test page title updated")
|
|
|
58 |
.click('#publish')
|
59 |
+
.pause(2000)
|
60 |
.wplogout()
|
61 |
.url(data.URLS.LOGIN + urlp)
|
62 |
+
.verify.containsText(".entry-title", "test page title updated")
|
63 |
+
.verify.containsText(".site-main", "test page created for testing")
|
64 |
},
|
65 |
|
66 |
'Step four : Page comment check ': function(browser) {
|