Skip to content

Commit 0702f7d

Browse files
committed
MC-16249: [CLOUD] Attachment is not opened on storefront
1 parent 90a479f commit 0702f7d

File tree

4 files changed

+70
-29
lines changed

4 files changed

+70
-29
lines changed

app/code/Magento/Customer/Model/CustomerRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function removeByEmail($customerEmail, $websiteId = null)
195195
$websiteId = $this->storeManager->getStore()->getWebsiteId();
196196
}
197197
$emailKey = $this->getEmailKey($customerEmail, $websiteId);
198-
if ($emailKey) {
198+
if (isset($this->customerRegistryByEmail[$emailKey])) {
199199
/** @var Customer $customer */
200200
$customer = $this->customerRegistryByEmail[$emailKey];
201201
unset($this->customerRegistryByEmail[$emailKey]);

app/code/Magento/PageCache/Model/App/Response/HttpPlugin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ class HttpPlugin
1919
*/
2020
public function beforeSendResponse(\Magento\Framework\App\Response\Http $subject)
2121
{
22-
if ($subject instanceof \Magento\Framework\App\PageCache\NotCacheableInterface) {
22+
if ($subject instanceof \Magento\Framework\App\PageCache\NotCacheableInterface || headers_sent()) {
2323
return;
2424
}
25+
2526
$subject->sendVary();
2627
}
2728
}

app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php

Lines changed: 66 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,75 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\PageCache\Test\Unit\Model\App\Response;
8-
9-
use Magento\PageCache\Model\App\Response\HttpPlugin;
10-
11-
class HttpPluginTest extends \PHPUnit\Framework\TestCase
12-
{
13-
/**
14-
* @param \Magento\Framework\App\Response\FileInterface $responseInstanceClass
15-
* @param int $sendVaryCalled
16-
*
17-
* @dataProvider beforeSendResponseDataProvider
18-
*/
19-
public function testBeforeSendResponse($responseInstanceClass, $sendVaryCalled)
7+
// @codingStandardsIgnoreStart
8+
namespace Magento\PageCache\Model\App\Response {
9+
$mockPHPFunctions = false;
10+
11+
function headers_sent()
2012
{
21-
/** @var \Magento\Framework\App\Response\Http | \PHPUnit_Framework_MockObject_MockObject $responseMock */
22-
$responseMock = $this->createMock($responseInstanceClass);
23-
$responseMock->expects($this->exactly($sendVaryCalled))
24-
->method('sendVary');
25-
$plugin = new HttpPlugin();
26-
$plugin->beforeSendResponse($responseMock);
13+
global $mockPHPFunctions;
14+
if ($mockPHPFunctions) {
15+
return false;
16+
}
17+
18+
return call_user_func_array('\headers_sent', func_get_args());
2719
}
20+
}
21+
22+
namespace Magento\PageCache\Test\Unit\Model\App\Response {
23+
24+
use Magento\Framework\App\Response\Http;
25+
use Magento\MediaStorage\Model\File\Storage\Response;
26+
use Magento\PageCache\Model\App\Response\HttpPlugin;
2827

29-
/**
30-
* @return array
31-
*/
32-
public function beforeSendResponseDataProvider()
28+
// @codingStandardsIgnoreEnd
29+
30+
class HttpPluginTest extends \PHPUnit\Framework\TestCase
3331
{
34-
return [
35-
[\Magento\Framework\App\Response\Http::class, 1],
36-
[\Magento\MediaStorage\Model\File\Storage\Response::class, 0]
37-
];
32+
/**
33+
* @inheritdoc
34+
*/
35+
protected function setUp()
36+
{
37+
global $mockPHPFunctions;
38+
$mockPHPFunctions = true;
39+
}
40+
41+
/**
42+
* @inheritdoc
43+
*/
44+
protected function tearDown()
45+
{
46+
global $mockPHPFunctions;
47+
$mockPHPFunctions = false;
48+
}
49+
50+
/**
51+
* @param string $responseInstanceClass
52+
* @param int $sendVaryCalled
53+
* @return void
54+
*
55+
* @dataProvider beforeSendResponseDataProvider
56+
*/
57+
public function testBeforeSendResponse(string $responseInstanceClass, int $sendVaryCalled): void
58+
{
59+
/** @var Http | \PHPUnit_Framework_MockObject_MockObject $responseMock */
60+
$responseMock = $this->createMock($responseInstanceClass);
61+
$responseMock->expects($this->exactly($sendVaryCalled))
62+
->method('sendVary');
63+
$plugin = new HttpPlugin();
64+
$plugin->beforeSendResponse($responseMock);
65+
}
66+
67+
/**
68+
* @return array
69+
*/
70+
public function beforeSendResponseDataProvider(): array
71+
{
72+
return [
73+
[Http::class, 1],
74+
[Response::class, 0]
75+
];
76+
}
3877
}
3978
}

dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/blacklist/common.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ dev/tests/api-functional/testsuite/Magento/Customer/Api/AddressRepositoryTest.ph
1414
dev/tests/api-functional/testsuite/Magento/Framework/Model/Entity/HydratorTest.php
1515
dev/tests/api-functional/testsuite/Magento/Integration/Model/AdminTokenServiceTest.php
1616
dev/tests/api-functional/testsuite/Magento/Integration/Model/CustomerTokenServiceTest.php
17+
app/code/Magento/PageCache/Test/Unit/Model/App/Response/HttpPluginTest.php

0 commit comments

Comments
 (0)