Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 547ad4a

Browse files
authored
Merge pull request #3210 from magento-qwerty/2.3-bugfixes-240918
[Qwerty] Bugfixes
2 parents e2c0d0f + 8487750 commit 547ad4a

File tree

16 files changed

+186
-93
lines changed

16 files changed

+186
-93
lines changed

app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteGroupPost.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Backend\Controller\Adminhtml\System\Store;
87

8+
use Magento\Framework\App\Action\HttpPostActionInterface;
99
use Magento\Framework\Controller\ResultFactory;
1010

11-
class DeleteGroupPost extends \Magento\Backend\Controller\Adminhtml\System\Store
11+
/**
12+
* Delete store.
13+
*/
14+
class DeleteGroupPost extends \Magento\Backend\Controller\Adminhtml\System\Store implements HttpPostActionInterface
1215
{
1316
/**
17+
* @inheritDoc
1418
* @return \Magento\Backend\Model\View\Result\Redirect
1519
*/
1620
public function execute()

app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteStorePost.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Backend\Controller\Adminhtml\System\Store;
87

8+
use Magento\Framework\App\Action\HttpPostActionInterface;
99
use Magento\Framework\Controller\ResultFactory;
1010

11-
class DeleteStorePost extends \Magento\Backend\Controller\Adminhtml\System\Store
11+
/**
12+
* Delete store view.
13+
*/
14+
class DeleteStorePost extends \Magento\Backend\Controller\Adminhtml\System\Store implements HttpPostActionInterface
1215
{
1316
/**
1417
* Delete store view post action

app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteWebsitePost.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
1010
use Magento\Framework\Controller\ResultFactory;
1111

12+
/**
13+
* Delete website.
14+
*/
1215
class DeleteWebsitePost extends \Magento\Backend\Controller\Adminhtml\System\Store implements HttpPostActionInterface
1316
{
1417
/**
18+
* @inheritDoc
1519
* @return \Magento\Backend\Model\View\Result\Redirect
1620
*/
1721
public function execute()

app/code/Magento/Catalog/Controller/Adminhtml/Category/Image/Upload.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
*/
66
namespace Magento\Catalog\Controller\Adminhtml\Category\Image;
77

8+
use Magento\Framework\App\Action\HttpPostActionInterface;
89
use Magento\Framework\Controller\ResultFactory;
910

1011
/**
1112
* Class Upload
1213
*/
13-
class Upload extends \Magento\Backend\App\Action
14+
class Upload extends \Magento\Backend\App\Action implements HttpPostActionInterface
1415
{
1516
/**
1617
* Image uploader
@@ -54,14 +55,6 @@ public function execute()
5455

5556
try {
5657
$result = $this->imageUploader->saveFileToTmpDir($imageId);
57-
58-
$result['cookie'] = [
59-
'name' => $this->_getSession()->getName(),
60-
'value' => $this->_getSession()->getSessionId(),
61-
'lifetime' => $this->_getSession()->getCookieLifetime(),
62-
'path' => $this->_getSession()->getCookiePath(),
63-
'domain' => $this->_getSession()->getCookieDomain(),
64-
];
6558
} catch (\Exception $e) {
6659
$result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
6760
}

app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -501,14 +501,6 @@ public function uploadFile($targetPath, $type = null)
501501
// create thumbnail
502502
$this->resizeFile($targetPath . '/' . $uploader->getUploadedFileName(), true);
503503

504-
$result['cookie'] = [
505-
'name' => $this->getSession()->getName(),
506-
'value' => $this->getSession()->getSessionId(),
507-
'lifetime' => $this->getSession()->getCookieLifetime(),
508-
'path' => $this->getSession()->getCookiePath(),
509-
'domain' => $this->getSession()->getCookieDomain(),
510-
];
511-
512504
return $result;
513505
}
514506

app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -440,14 +440,7 @@ public function testUploadFile()
440440
$thumbnailDestination = $thumbnailTargetPath . '/' . $fileName;
441441
$type = 'image';
442442
$result = [
443-
'result',
444-
'cookie' => [
445-
'name' => 'session_name',
446-
'value' => '1',
447-
'lifetime' => '50',
448-
'path' => 'cookie/path',
449-
'domain' => 'cookie_domain',
450-
],
443+
'result'
451444
];
452445
$uploader = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Uploader::class)
453446
->disableOriginalConstructor()
@@ -507,17 +500,6 @@ public function testUploadFile()
507500

508501
$this->adapterFactoryMock->expects($this->atLeastOnce())->method('create')->willReturn($image);
509502

510-
$this->sessionMock->expects($this->atLeastOnce())->method('getName')
511-
->willReturn($result['cookie']['name']);
512-
$this->sessionMock->expects($this->atLeastOnce())->method('getSessionId')
513-
->willReturn($result['cookie']['value']);
514-
$this->sessionMock->expects($this->atLeastOnce())->method('getCookieLifetime')
515-
->willReturn($result['cookie']['lifetime']);
516-
$this->sessionMock->expects($this->atLeastOnce())->method('getCookiePath')
517-
->willReturn($result['cookie']['path']);
518-
$this->sessionMock->expects($this->atLeastOnce())->method('getCookieDomain')
519-
->willReturn($result['cookie']['domain']);
520-
521503
$this->assertEquals($result, $this->imagesStorage->uploadFile($targetPath, $type));
522504
}
523505
}

app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/File/Upload.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Downloadable\Controller\Adminhtml\Downloadable\File;
87

8+
use Magento\Framework\App\Action\HttpPostActionInterface;
99
use Magento\Framework\Controller\ResultFactory;
1010

11-
class Upload extends \Magento\Downloadable\Controller\Adminhtml\Downloadable\File
11+
/**
12+
* Class Upload
13+
*
14+
* @package Magento\Downloadable\Controller\Adminhtml\Downloadable\File
15+
*/
16+
class Upload extends \Magento\Downloadable\Controller\Adminhtml\Downloadable\File implements HttpPostActionInterface
1217
{
1318
/**
1419
* @var \Magento\Downloadable\Model\Link
@@ -96,17 +101,10 @@ public function execute()
96101
$relativePath = rtrim($tmpPath, '/') . '/' . ltrim($result['file'], '/');
97102
$this->storageDatabase->saveFile($relativePath);
98103
}
99-
100-
$result['cookie'] = [
101-
'name' => $this->_getSession()->getName(),
102-
'value' => $this->_getSession()->getSessionId(),
103-
'lifetime' => $this->_getSession()->getCookieLifetime(),
104-
'path' => $this->_getSession()->getCookiePath(),
105-
'domain' => $this->_getSession()->getCookieDomain(),
106-
];
107104
} catch (\Exception $e) {
108105
$result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
109106
}
107+
110108
return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($result);
111109
}
112110
}

app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Downloadable/File/UploadTest.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ class UploadTest extends \PHPUnit\Framework\TestCase
5959
*/
6060
protected $fileHelper;
6161

62-
/**
63-
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Model\Session
64-
*/
65-
protected $session;
66-
6762
/**
6863
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Controller\ResultFactory
6964
*/
@@ -81,9 +76,6 @@ protected function setUp()
8176
->disableOriginalConstructor()
8277
->setMethods(['create'])
8378
->getMock();
84-
$this->session = $this->getMockBuilder(\Magento\Backend\Model\Session::class)
85-
->disableOriginalConstructor()
86-
->getMock();
8779
$this->resultFactory = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class)
8880
->disableOriginalConstructor()
8981
->setMethods(['create'])
@@ -108,9 +100,6 @@ protected function setUp()
108100
$this->context->expects($this->any())
109101
->method('getRequest')
110102
->will($this->returnValue($this->request));
111-
$this->context->expects($this->any())
112-
->method('getSession')
113-
->will($this->returnValue($this->session));
114103
$this->context->expects($this->any())
115104
->method('getResultFactory')
116105
->will($this->returnValue($this->resultFactory));
@@ -154,11 +143,6 @@ public function testExecute()
154143
$this->uploaderFactory->expects($this->once())->method('create')->willReturn($uploader);
155144
$this->fileHelper->expects($this->once())->method('uploadFromTmp')->willReturn($data);
156145
$this->storageDatabase->expects($this->once())->method('saveFile');
157-
$this->session->expects($this->once())->method('getName')->willReturn('Name');
158-
$this->session->expects($this->once())->method('getSessionId')->willReturn('SessionId');
159-
$this->session->expects($this->once())->method('getCookieLifetime')->willReturn('CookieLifetime');
160-
$this->session->expects($this->once())->method('getCookiePath')->willReturn('CookiePath');
161-
$this->session->expects($this->once())->method('getCookieDomain')->willReturn('CookieDomain');
162146
$this->resultFactory->expects($this->once())->method('create')->willReturn($resultJson);
163147
$resultJson->expects($this->once())->method('setData')->willReturnSelf();
164148

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageCache\Model\System\Config\Backend;
10+
11+
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\Phrase;
13+
14+
/**
15+
* Access List config field.
16+
*/
17+
class AccessList extends Varnish
18+
{
19+
/**
20+
* @inheritDoc
21+
*/
22+
public function beforeSave()
23+
{
24+
parent::beforeSave();
25+
26+
$value = $this->getValue();
27+
if (!is_string($value) || !preg_match('/^[\w\s\.\-\,\:]+$/', $value)) {
28+
throw new LocalizedException(
29+
new Phrase(
30+
'Access List value "%1" is not valid. '
31+
.'Please use only IP addresses and host names.',
32+
[$value]
33+
)
34+
);
35+
}
36+
}
37+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageCache\Test\Unit\Model\System\Config\Backend;
10+
11+
use Magento\PageCache\Model\System\Config\Backend\AccessList;
12+
use PHPUnit\Framework\TestCase;
13+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
14+
use Magento\Framework\App\Config\ScopeConfigInterface;
15+
16+
class AccessListTest extends TestCase
17+
{
18+
/**
19+
* @var AccessList
20+
*/
21+
private $accessList;
22+
23+
/**
24+
* @inheritDoc
25+
*/
26+
protected function setUp()
27+
{
28+
$objectManager = new ObjectManager($this);
29+
$configMock = $this->getMockForAbstractClass(
30+
ScopeConfigInterface::class
31+
);
32+
$configMock->expects($this->any())
33+
->method('getValue')
34+
->with('system/full_page_cache/default')
35+
->willReturn(['access_list' => 'localhost']);
36+
$this->accessList = $objectManager->getObject(
37+
AccessList::class,
38+
[
39+
'config' => $configMock,
40+
'data' => ['field' => 'access_list']
41+
]
42+
);
43+
}
44+
45+
/**
46+
* @return array
47+
*/
48+
public function getValidValues(): array
49+
{
50+
return [
51+
['localhost', 'localhost'],
52+
[null, 'localhost'],
53+
['127.0.0.1', '127.0.0.1'],
54+
['127.0.0.1, localhost, ::2', '127.0.0.1, localhost, ::2'],
55+
];
56+
}
57+
58+
/**
59+
* @param mixed $value
60+
* @param mixed $expectedValue
61+
* @dataProvider getValidValues
62+
*/
63+
public function testBeforeSave($value, $expectedValue)
64+
{
65+
$this->accessList->setValue($value);
66+
$this->accessList->beforeSave();
67+
$this->assertEquals($expectedValue, $this->accessList->getValue());
68+
}
69+
70+
/**
71+
* @return array
72+
*/
73+
public function getInvalidValues(): array
74+
{
75+
return [
76+
['\\bull val\\'],
77+
['{*I am not an IP*}'],
78+
['{*I am not an IP*}, 127.0.0.1'],
79+
];
80+
}
81+
82+
/**
83+
* @param mixed $value
84+
* @expectedException \Magento\Framework\Exception\LocalizedException
85+
* @dataProvider getInvalidValues
86+
*/
87+
public function testBeforeSaveInvalid($value)
88+
{
89+
$this->accessList->setValue($value);
90+
$this->accessList->beforeSave();
91+
}
92+
}

app/code/Magento/PageCache/etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<label>Access list</label>
2121
<comment>IPs access list separated with ',' that can purge Varnish configuration for config file generation.
2222
If field is empty default value localhost will be saved.</comment>
23-
<backend_model>Magento\PageCache\Model\System\Config\Backend\Varnish</backend_model>
23+
<backend_model>Magento\PageCache\Model\System\Config\Backend\AccessList</backend_model>
2424
<depends>
2525
<field id="caching_application">1</field>
2626
</depends>

app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ define([
8787
* @private
8888
*/
8989
_doUpdate: function () {
90+
var uploaderLinkUrl,
91+
uploaderLink;
92+
9093
this.reset();
9194
this.element.find(this.options.container).append(
9295
'<div class="' +
@@ -105,20 +108,15 @@ define([
105108
this.element.find(this.options.metaData.DOM.duration).text(this.options.metaData.data.duration);
106109

107110
if (this.options.videoProvider === 'youtube') {
108-
this.element.find(this.options.metaData.DOM.uploader).html(
109-
'<a href="https://youtube.com/channel/' +
110-
this.options.metaData.data.uploaderUrl +
111-
'" target="_blank">' +
112-
this.options.metaData.data.uploader +
113-
'</a>'
114-
);
111+
uploaderLinkUrl = 'https://youtube.com/channel/' + this.options.metaData.data.uploaderUrl;
115112
} else if (this.options.videoProvider === 'vimeo') {
116-
this.element.find(this.options.metaData.DOM.uploader).html(
117-
'<a href="' +
118-
this.options.metaData.data.uploaderUrl +
119-
'" target="_blank">' + this.options.metaData.data.uploader +
120-
'</a>');
113+
uploaderLinkUrl = this.options.metaData.data.uploaderUrl;
121114
}
115+
uploaderLink = document.createElement('a');
116+
uploaderLink.setAttribute('href', uploaderLinkUrl);
117+
uploaderLink.setAttribute('target', '_blank');
118+
uploaderLink.innerText = this.options.metaData.data.uploader;
119+
this.element.find(this.options.metaData.DOM.uploader)[0].appendChild(uploaderLink);
122120
this.element.find('.' + this.options.videoClass).productVideoLoader();
123121

124122
},

0 commit comments

Comments
 (0)