Skip to content

Commit a7dd24b

Browse files
Merge branch 'master' into chore/PE2-1049/additional-logging
2 parents d985098 + fdd616c commit a7dd24b

File tree

9 files changed

+35
-27
lines changed

9 files changed

+35
-27
lines changed

Block/GeoIp/GetAction.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
1919
* @license BSD, see LICENSE_FASTLY_CDN.txt
2020
*/
21+
2122
namespace Fastly\Cdn\Block\GeoIp;
2223

2324
use Fastly\Cdn\Model\Config;
@@ -60,13 +61,14 @@ class GetAction extends AbstractBlock
6061
* @param EncoderInterface $urlEncoder
6162
*/
6263
public function __construct(
63-
Config $config,
64-
Context $context,
65-
Response $response,
66-
Url $url,
64+
Config $config,
65+
Context $context,
66+
Response $response,
67+
Url $url,
6768
EncoderInterface $urlEncoder,
68-
array $data = []
69-
) {
69+
array $data = []
70+
)
71+
{
7072
$this->config = $config;
7173
$this->response = $response;
7274
$this->url = $url;
@@ -92,8 +94,8 @@ protected function _toHtml() // @codingStandardsIgnoreLine - required by parent
9294
$currentUrl = $this->url->getCurrentUrl();
9395
$baseUrl = $this->url->getBaseUrl();
9496
$webTypeUrl = $this->url->getBaseUrl(['_type' => Url::URL_TYPE_WEB]);
95-
96-
if (strpos($currentUrl, $baseUrl) !== false) {
97+
98+
if (strpos($currentUrl, rtrim($baseUrl, "/")) !== false) {
9799
$targetUrl = $currentUrl;
98100
} else {
99101
$targetUrl = str_replace($webTypeUrl, $baseUrl, $currentUrl);
@@ -109,7 +111,7 @@ protected function _toHtml() // @codingStandardsIgnoreLine - required by parent
109111
$this->response->setHeader("x-esi", "1");
110112
}
111113
// Due to Varnish parser limitations HTTPS ESIs are not supported so we need to turn them into HTTP URLs
112-
// This does not mean that request will go over HTTP. ESI subrequest will go out to the backend that is
114+
// This does not mean that request will go over HTTP. ESI subrequest will go out to the backend that is
113115
// currently specified so if it's HTTPS it will go over HTTPS
114116
return sprintf(
115117
'<esi:include src=\'%s\' />',

Model/FrontControllerPlugin.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -334,26 +334,24 @@ private function verifyBots($ip)
334334
return false;
335335
}
336336

337-
private function readMaintenanceIp($ip)
337+
private function readMaintenanceIp($clientIps)
338338
{
339339
$tag = self::FASTLY_CACHE_MAINTENANCE_IP_FILE_TAG;
340-
$data = json_decode($this->cache->load($tag));
341-
if (empty($data)) {
342-
$data = [];
340+
$allowedIps = json_decode($this->cache->load($tag));
341+
if (empty($allowedIps)) {
342+
$allowedIps = [];
343343
$flagDir = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
344344
if ($flagDir->isExist('.maintenance.ip')) {
345345
$temp = $flagDir->readFile('.maintenance.ip');
346-
$data = explode(',', trim($temp));
347-
$this->cache->save(json_encode($data), $tag, []);
346+
$allowedIps = explode(',', trim($temp));
347+
$this->cache->save(json_encode($allowedIps), $tag, []);
348348
}
349349
}
350350

351-
foreach ($data as $key => $value) {
352-
if (!empty($value) && trim($value) == $ip) {
353-
return true;
354-
}
355-
}
356-
return false;
351+
$ips = array_map("trim", explode(",", $clientIps));
352+
$isAllowed = array_intersect($allowedIps, $ips);
353+
354+
return !empty($isAllowed);
357355
}
358356

359357
private function log($message)

Model/Layout/LayoutPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function afterGenerateElements(\Magento\Framework\View\Layout $subject):
9898
public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result) // @codingStandardsIgnoreLine - unused parameter
9999
{
100100
if ($this->config->getType() === Config::FASTLY) {
101-
$this->response->setHeader("Fastly-Module-Enabled", "1.2.214", true);
101+
$this->response->setHeader("Fastly-Module-Enabled", "1.2.216", true);
102102
}
103103

104104
return $result;

Release-Notes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Fastly_Cdn Release Notes
22

3+
## 1.2.216
4+
5+
- Fix for GEOIP redirection causes 404 in specific cases https://github.com/fastly/fastly-magento2/pull/694
6+
7+
## 1.2.215
8+
9+
- Fix for checking if current IP is in maintenance IP list https://github.com/fastly/fastly-magento2/pull/692
10+
311
## 1.2.214
412

513
- Rate limiting doesn't work correctly when store codes are involved https://github.com/fastly/fastly-magento2/pull/689

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.214
1+
1.2.216

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"zordius/lightncandy": "^1.2"
1313
},
1414
"type": "magento2-module",
15-
"version": "1.2.214",
15+
"version": "1.2.216",
1616
"license": "BSD-3-Clause",
1717
"autoload": {
1818
"files": [ "registration.php" ],

etc/vcl_snippets/deliver.vcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
# Add an easy way to see whether custom Fastly VCL has been uploaded
4141
if ( req.http.Fastly-Debug ) {
42-
set resp.http.Fastly-Magento-VCL-Uploaded = "1.2.214";
42+
set resp.http.Fastly-Magento-VCL-Uploaded = "1.2.216";
4343
if (table.lookup(magentomodule_config, "allow_super_users_during_maint", "0") == "1") {
4444
set resp.http.Fastly-Magento-Maintenance-Mode = "on";
4545
}

etc/vcl_snippets/miss.vcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
unset bereq.http.Accept-Encoding;
44

55
# Send VCL version uploaded to the backend
6-
set bereq.http.Fastly-Magento-VCL-Uploaded = "1.2.214";
6+
set bereq.http.Fastly-Magento-VCL-Uploaded = "1.2.216";

etc/vcl_snippets/pass.vcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
}
1313

1414
# Send VCL version uploaded to the backend
15-
set bereq.http.Fastly-Magento-VCL-Uploaded = "1.2.214";
15+
set bereq.http.Fastly-Magento-VCL-Uploaded = "1.2.216";

0 commit comments

Comments
 (0)