-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3210 from magento-qwerty/2.3-bugfixes-240918
[Qwerty] Bugfixes
- Loading branch information
Showing
16 changed files
with
186 additions
and
93 deletions.
There are no files selected for viewing
8 changes: 6 additions & 2 deletions
8
app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteGroupPost.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteStorePost.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
app/code/Magento/PageCache/Model/System/Config/Backend/AccessList.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\PageCache\Model\System\Config\Backend; | ||
|
||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\Phrase; | ||
|
||
/** | ||
* Access List config field. | ||
*/ | ||
class AccessList extends Varnish | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function beforeSave() | ||
{ | ||
parent::beforeSave(); | ||
|
||
$value = $this->getValue(); | ||
if (!is_string($value) || !preg_match('/^[\w\s\.\-\,\:]+$/', $value)) { | ||
throw new LocalizedException( | ||
new Phrase( | ||
'Access List value "%1" is not valid. ' | ||
.'Please use only IP addresses and host names.', | ||
[$value] | ||
) | ||
); | ||
} | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
app/code/Magento/PageCache/Test/Unit/Model/System/Config/Backend/AccessListTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Magento\PageCache\Test\Unit\Model\System\Config\Backend; | ||
|
||
use Magento\PageCache\Model\System\Config\Backend\AccessList; | ||
use PHPUnit\Framework\TestCase; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
|
||
class AccessListTest extends TestCase | ||
{ | ||
/** | ||
* @var AccessList | ||
*/ | ||
private $accessList; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function setUp() | ||
{ | ||
$objectManager = new ObjectManager($this); | ||
$configMock = $this->getMockForAbstractClass( | ||
ScopeConfigInterface::class | ||
); | ||
$configMock->expects($this->any()) | ||
->method('getValue') | ||
->with('system/full_page_cache/default') | ||
->willReturn(['access_list' => 'localhost']); | ||
$this->accessList = $objectManager->getObject( | ||
AccessList::class, | ||
[ | ||
'config' => $configMock, | ||
'data' => ['field' => 'access_list'] | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getValidValues(): array | ||
{ | ||
return [ | ||
['localhost', 'localhost'], | ||
[null, 'localhost'], | ||
['127.0.0.1', '127.0.0.1'], | ||
['127.0.0.1, localhost, ::2', '127.0.0.1, localhost, ::2'], | ||
]; | ||
} | ||
|
||
/** | ||
* @param mixed $value | ||
* @param mixed $expectedValue | ||
* @dataProvider getValidValues | ||
*/ | ||
public function testBeforeSave($value, $expectedValue) | ||
{ | ||
$this->accessList->setValue($value); | ||
$this->accessList->beforeSave(); | ||
$this->assertEquals($expectedValue, $this->accessList->getValue()); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getInvalidValues(): array | ||
{ | ||
return [ | ||
['\\bull val\\'], | ||
['{*I am not an IP*}'], | ||
['{*I am not an IP*}, 127.0.0.1'], | ||
]; | ||
} | ||
|
||
/** | ||
* @param mixed $value | ||
* @expectedException \Magento\Framework\Exception\LocalizedException | ||
* @dataProvider getInvalidValues | ||
*/ | ||
public function testBeforeSaveInvalid($value) | ||
{ | ||
$this->accessList->setValue($value); | ||
$this->accessList->beforeSave(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.