Version Description
Download this release
Release Info
Developer | manatarms |
Plugin | Cloudflare |
Version | 4.9.0 |
Comparing to | |
See all releases |
Code changes from version 4.8.3 to 4.9.0
- output.log +11 -10
- src/WordPress/Hooks.php +52 -27
- vendor/autoload.php +1 -1
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +5 -5
output.log
CHANGED
@@ -16,36 +16,37 @@ php-7.4-build2: Pulling from cloudflare/cloudflare-wordpress/php-actions_compose
|
|
16 |
5571c1cd7f43: Pulling fs layer
|
17 |
65564f077fec: Pulling fs layer
|
18 |
4d1e94121e00: Pulling fs layer
|
19 |
-
4612e05a72cf: Waiting
|
20 |
-
9b2beae78beb: Waiting
|
21 |
-
79c03e12047a: Waiting
|
22 |
51393fef6543: Waiting
|
23 |
5571c1cd7f43: Waiting
|
24 |
65564f077fec: Waiting
|
25 |
4d1e94121e00: Waiting
|
|
|
|
|
|
|
26 |
320f26ee9b1c: Verifying Checksum
|
27 |
320f26ee9b1c: Download complete
|
28 |
-
|
29 |
-
30e209609427: Download complete
|
30 |
801bfaa63ef2: Download complete
|
31 |
801bfaa63ef2: Pull complete
|
32 |
4612e05a72cf: Verifying Checksum
|
33 |
4612e05a72cf: Download complete
|
34 |
-
30e209609427:
|
35 |
-
|
36 |
-
79c03e12047a: Download complete
|
37 |
9b2beae78beb: Verifying Checksum
|
38 |
9b2beae78beb: Download complete
|
|
|
39 |
320f26ee9b1c: Pull complete
|
|
|
|
|
40 |
4612e05a72cf: Pull complete
|
41 |
5571c1cd7f43: Verifying Checksum
|
42 |
5571c1cd7f43: Download complete
|
43 |
9b2beae78beb: Pull complete
|
44 |
-
65564f077fec: Verifying Checksum
|
45 |
-
65564f077fec: Download complete
|
46 |
51393fef6543: Verifying Checksum
|
47 |
51393fef6543: Download complete
|
48 |
79c03e12047a: Pull complete
|
|
|
|
|
49 |
4d1e94121e00: Verifying Checksum
|
50 |
4d1e94121e00: Download complete
|
51 |
51393fef6543: Pull complete
|
16 |
5571c1cd7f43: Pulling fs layer
|
17 |
65564f077fec: Pulling fs layer
|
18 |
4d1e94121e00: Pulling fs layer
|
|
|
|
|
|
|
19 |
51393fef6543: Waiting
|
20 |
5571c1cd7f43: Waiting
|
21 |
65564f077fec: Waiting
|
22 |
4d1e94121e00: Waiting
|
23 |
+
4612e05a72cf: Waiting
|
24 |
+
9b2beae78beb: Waiting
|
25 |
+
79c03e12047a: Waiting
|
26 |
320f26ee9b1c: Verifying Checksum
|
27 |
320f26ee9b1c: Download complete
|
28 |
+
801bfaa63ef2: Verifying Checksum
|
|
|
29 |
801bfaa63ef2: Download complete
|
30 |
801bfaa63ef2: Pull complete
|
31 |
4612e05a72cf: Verifying Checksum
|
32 |
4612e05a72cf: Download complete
|
33 |
+
30e209609427: Verifying Checksum
|
34 |
+
30e209609427: Download complete
|
|
|
35 |
9b2beae78beb: Verifying Checksum
|
36 |
9b2beae78beb: Download complete
|
37 |
+
30e209609427: Pull complete
|
38 |
320f26ee9b1c: Pull complete
|
39 |
+
79c03e12047a: Verifying Checksum
|
40 |
+
79c03e12047a: Download complete
|
41 |
4612e05a72cf: Pull complete
|
42 |
5571c1cd7f43: Verifying Checksum
|
43 |
5571c1cd7f43: Download complete
|
44 |
9b2beae78beb: Pull complete
|
|
|
|
|
45 |
51393fef6543: Verifying Checksum
|
46 |
51393fef6543: Download complete
|
47 |
79c03e12047a: Pull complete
|
48 |
+
65564f077fec: Verifying Checksum
|
49 |
+
65564f077fec: Download complete
|
50 |
4d1e94121e00: Verifying Checksum
|
51 |
4d1e94121e00: Download complete
|
52 |
51393fef6543: Pull complete
|
src/WordPress/Hooks.php
CHANGED
@@ -137,7 +137,7 @@ class Hooks
|
|
137 |
}
|
138 |
}
|
139 |
|
140 |
-
public function purgeCacheByRelevantURLs($
|
141 |
{
|
142 |
if ($this->isPluginSpecificCacheEnabled() || $this->isAutomaticPlatformOptimizationEnabled()) {
|
143 |
$wpDomainList = $this->integrationAPI->getDomainList();
|
@@ -145,26 +145,47 @@ class Hooks
|
|
145 |
return;
|
146 |
}
|
147 |
$wpDomain = $wpDomainList[0];
|
148 |
-
|
149 |
-
|
150 |
-
if (wp_is_post_autosave($postId) || wp_is_post_revision($postId)) {
|
151 |
return;
|
152 |
}
|
153 |
|
154 |
-
$
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
|
159 |
-
|
160 |
-
if (!is_a($savedPost, 'WP_Post')) {
|
161 |
return;
|
162 |
}
|
163 |
|
164 |
-
|
165 |
-
$urls =
|
166 |
|
167 |
-
$zoneTag = $this->api->getZoneTag($wpDomain);
|
168 |
$activePageRules = $this->api->getPageRules($zoneTag, "active");
|
169 |
|
170 |
// Fetch the page rules and should we not have any hints of cache
|
@@ -175,20 +196,13 @@ class Hooks
|
|
175 |
$urls = array_filter($urls, array($this, "pathHasCachableFileExtension"));
|
176 |
}
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
if (!Utils::strEndsWith(parse_url($url, PHP_URL_HOST), $wpDomain)) {
|
181 |
-
unset($urls[$key]);
|
182 |
-
}
|
183 |
-
}
|
184 |
-
|
185 |
-
$hasAlwaysUseHTTPSOverrideDisabled = $this->pageRuleContains($activePageRules, "always_use_https", "off");
|
186 |
-
if ($this->zoneSettingAlwaysUseHTTPSEnabled($zoneTag) && !$hasAlwaysUseHTTPSOverrideDisabled) {
|
187 |
-
$this->logger->debug("always_use_https is enabled without page rule overrides present, removing HTTP based URLs");
|
188 |
$urls = array_filter($urls, array($this, "urlIsHTTPS"));
|
189 |
}
|
190 |
|
191 |
-
if (
|
|
|
192 |
$chunks = array_chunk($urls, 30);
|
193 |
|
194 |
foreach ($chunks as $chunk) {
|
@@ -322,10 +336,13 @@ class Hooks
|
|
322 |
}
|
323 |
$listofurls = array_merge(
|
324 |
$listofurls,
|
325 |
-
|
326 |
);
|
327 |
}
|
328 |
|
|
|
|
|
|
|
329 |
// Purge https and http URLs
|
330 |
if (function_exists('force_ssl_admin') && force_ssl_admin()) {
|
331 |
$listofurls = array_merge($listofurls, str_replace('https://', 'http://', $listofurls));
|
@@ -333,9 +350,6 @@ class Hooks
|
|
333 |
$listofurls = array_merge($listofurls, str_replace('http://', 'https://', $listofurls));
|
334 |
}
|
335 |
|
336 |
-
// Clean array if row empty
|
337 |
-
$listofurls = array_filter($listofurls);
|
338 |
-
|
339 |
return $listofurls;
|
340 |
}
|
341 |
|
@@ -467,6 +481,17 @@ class Hooks
|
|
467 |
|
468 |
foreach ($pagerules as $pagerule) {
|
469 |
foreach ($pagerule["actions"] as $action) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
470 |
if ($action["id"] == $key && $action["value"] == $value) {
|
471 |
return true;
|
472 |
}
|
137 |
}
|
138 |
}
|
139 |
|
140 |
+
public function purgeCacheByRelevantURLs($postIds)
|
141 |
{
|
142 |
if ($this->isPluginSpecificCacheEnabled() || $this->isAutomaticPlatformOptimizationEnabled()) {
|
143 |
$wpDomainList = $this->integrationAPI->getDomainList();
|
145 |
return;
|
146 |
}
|
147 |
$wpDomain = $wpDomainList[0];
|
148 |
+
$zoneTag = $this->api->getZoneTag($wpDomain);
|
149 |
+
if (!isset($zoneTag)) {
|
|
|
150 |
return;
|
151 |
}
|
152 |
|
153 |
+
$postIds = (array) $postIds;
|
154 |
+
$urls = [];
|
155 |
+
foreach ($postIds as $postId) {
|
156 |
+
// Do not purge for autosaves or updates to post revisions.
|
157 |
+
if (wp_is_post_autosave($postId) || wp_is_post_revision($postId)) {
|
158 |
+
continue;
|
159 |
+
}
|
160 |
+
|
161 |
+
$postType = get_post_type_object(get_post_type($postId));
|
162 |
+
if (!is_post_type_viewable($postType)) {
|
163 |
+
continue;
|
164 |
+
}
|
165 |
+
|
166 |
+
$savedPost = get_post($postId);
|
167 |
+
if (!is_a($savedPost, 'WP_Post')) {
|
168 |
+
continue;
|
169 |
+
}
|
170 |
+
|
171 |
+
$relatedUrls = apply_filters('cloudflare_purge_by_url', $this->getPostRelatedLinks($postId), $postId);
|
172 |
+
$urls = array_merge($urls, $relatedUrls);
|
173 |
+
}
|
174 |
+
|
175 |
+
// Don't attempt to purge anything outside of the provided zone.
|
176 |
+
foreach ($urls as $key => $url) {
|
177 |
+
if (!Utils::strEndsWith(parse_url($url, PHP_URL_HOST), $wpDomain)) {
|
178 |
+
unset($urls[$key]);
|
179 |
+
}
|
180 |
}
|
181 |
|
182 |
+
if (empty($urls)) {
|
|
|
183 |
return;
|
184 |
}
|
185 |
|
186 |
+
// Filter by unique urls
|
187 |
+
$urls = array_values(array_filter(array_unique($urls)));
|
188 |
|
|
|
189 |
$activePageRules = $this->api->getPageRules($zoneTag, "active");
|
190 |
|
191 |
// Fetch the page rules and should we not have any hints of cache
|
196 |
$urls = array_filter($urls, array($this, "pathHasCachableFileExtension"));
|
197 |
}
|
198 |
|
199 |
+
if ($this->zoneSettingAlwaysUseHTTPSEnabled($zoneTag)) {
|
200 |
+
$this->logger->debug("zone level always_use_https is enabled, removing HTTP based URLs");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
$urls = array_filter($urls, array($this, "urlIsHTTPS"));
|
202 |
}
|
203 |
|
204 |
+
if (!empty($urls)) {
|
205 |
+
do_action('cloudflare_purged_urls', $urls, $postIds);
|
206 |
$chunks = array_chunk($urls, 30);
|
207 |
|
208 |
foreach ($chunks as $chunk) {
|
336 |
}
|
337 |
$listofurls = array_merge(
|
338 |
$listofurls,
|
339 |
+
$attachmentUrls
|
340 |
);
|
341 |
}
|
342 |
|
343 |
+
// Clean array and get unique values
|
344 |
+
$listofurls = array_values(array_filter(array_unique($listofurls)));
|
345 |
+
|
346 |
// Purge https and http URLs
|
347 |
if (function_exists('force_ssl_admin') && force_ssl_admin()) {
|
348 |
$listofurls = array_merge($listofurls, str_replace('https://', 'http://', $listofurls));
|
350 |
$listofurls = array_merge($listofurls, str_replace('http://', 'https://', $listofurls));
|
351 |
}
|
352 |
|
|
|
|
|
|
|
353 |
return $listofurls;
|
354 |
}
|
355 |
|
481 |
|
482 |
foreach ($pagerules as $pagerule) {
|
483 |
foreach ($pagerule["actions"] as $action) {
|
484 |
+
// always_use_https can only be toggled on for a URL but doesn't
|
485 |
+
// have a value so we merely check the presence of the key
|
486 |
+
// instead.
|
487 |
+
if ($action["id"] == "always_use_https" && $key == "always_use_https") {
|
488 |
+
return true;
|
489 |
+
}
|
490 |
+
|
491 |
+
if (!array_key_exists("value", $action)) {
|
492 |
+
continue;
|
493 |
+
}
|
494 |
+
|
495 |
if ($action["id"] == $key && $action["value"] == $value) {
|
496 |
return true;
|
497 |
}
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInitd4f4c0b99524330ed6fabcae4013f5c5::getLoader();
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -22,15 +22,15 @@ class ComposerAutoloaderInit959bcbb6a94a41bb92a90d5d095538b7
|
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
-
spl_autoload_register(array('
|
26 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
27 |
-
spl_autoload_unregister(array('
|
28 |
|
29 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
30 |
if ($useStaticLoader) {
|
31 |
require_once __DIR__ . '/autoload_static.php';
|
32 |
|
33 |
-
call_user_func(\Composer\Autoload\
|
34 |
} else {
|
35 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
foreach ($map as $namespace => $path) {
|
@@ -51,19 +51,19 @@ class ComposerAutoloaderInit959bcbb6a94a41bb92a90d5d095538b7
|
|
51 |
$loader->register(true);
|
52 |
|
53 |
if ($useStaticLoader) {
|
54 |
-
$includeFiles = Composer\Autoload\
|
55 |
} else {
|
56 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
57 |
}
|
58 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
59 |
-
|
60 |
}
|
61 |
|
62 |
return $loader;
|
63 |
}
|
64 |
}
|
65 |
|
66 |
-
function
|
67 |
{
|
68 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
69 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInitd4f4c0b99524330ed6fabcae4013f5c5
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
+
spl_autoload_register(array('ComposerAutoloaderInitd4f4c0b99524330ed6fabcae4013f5c5', 'loadClassLoader'), true, true);
|
26 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
27 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitd4f4c0b99524330ed6fabcae4013f5c5', 'loadClassLoader'));
|
28 |
|
29 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
30 |
if ($useStaticLoader) {
|
31 |
require_once __DIR__ . '/autoload_static.php';
|
32 |
|
33 |
+
call_user_func(\Composer\Autoload\ComposerStaticInitd4f4c0b99524330ed6fabcae4013f5c5::getInitializer($loader));
|
34 |
} else {
|
35 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
foreach ($map as $namespace => $path) {
|
51 |
$loader->register(true);
|
52 |
|
53 |
if ($useStaticLoader) {
|
54 |
+
$includeFiles = Composer\Autoload\ComposerStaticInitd4f4c0b99524330ed6fabcae4013f5c5::$files;
|
55 |
} else {
|
56 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
57 |
}
|
58 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
59 |
+
composerRequired4f4c0b99524330ed6fabcae4013f5c5($fileIdentifier, $file);
|
60 |
}
|
61 |
|
62 |
return $loader;
|
63 |
}
|
64 |
}
|
65 |
|
66 |
+
function composerRequired4f4c0b99524330ed6fabcae4013f5c5($fileIdentifier, $file)
|
67 |
{
|
68 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
69 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php',
|
@@ -69,10 +69,10 @@ class ComposerStaticInit959bcbb6a94a41bb92a90d5d095538b7
|
|
69 |
public static function getInitializer(ClassLoader $loader)
|
70 |
{
|
71 |
return \Closure::bind(function () use ($loader) {
|
72 |
-
$loader->prefixLengthsPsr4 =
|
73 |
-
$loader->prefixDirsPsr4 =
|
74 |
-
$loader->prefixesPsr0 =
|
75 |
-
$loader->classMap =
|
76 |
|
77 |
}, null, ClassLoader::class);
|
78 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInitd4f4c0b99524330ed6fabcae4013f5c5
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php',
|
69 |
public static function getInitializer(ClassLoader $loader)
|
70 |
{
|
71 |
return \Closure::bind(function () use ($loader) {
|
72 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInitd4f4c0b99524330ed6fabcae4013f5c5::$prefixLengthsPsr4;
|
73 |
+
$loader->prefixDirsPsr4 = ComposerStaticInitd4f4c0b99524330ed6fabcae4013f5c5::$prefixDirsPsr4;
|
74 |
+
$loader->prefixesPsr0 = ComposerStaticInitd4f4c0b99524330ed6fabcae4013f5c5::$prefixesPsr0;
|
75 |
+
$loader->classMap = ComposerStaticInitd4f4c0b99524330ed6fabcae4013f5c5::$classMap;
|
76 |
|
77 |
}, null, ClassLoader::class);
|
78 |
}
|