Skip to content

Commit cce6671

Browse files
Merge MAGETWO-72048 into 2.3-bugfixes-240918
2 parents 17a4355 + de61c15 commit cce6671

File tree

8 files changed

+19
-72
lines changed

8 files changed

+19
-72
lines changed

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

app/code/Magento/Theme/Model/Wysiwyg/Storage.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111

1212
use Magento\Framework\App\Filesystem\DirectoryList;
1313

14+
/**
15+
* Class Storage
16+
*
17+
* @package Magento\Theme\Model\Wysiwyg
18+
*/
1419
class Storage
1520
{
1621
/**
@@ -127,14 +132,6 @@ public function uploadFile($targetPath)
127132

128133
$this->_createThumbnail($targetPath . '/' . $uploader->getUploadedFileName());
129134

130-
$result['cookie'] = [
131-
'name' => $this->_helper->getSession()->getName(),
132-
'value' => $this->_helper->getSession()->getSessionId(),
133-
'lifetime' => $this->_helper->getSession()->getCookieLifetime(),
134-
'path' => $this->_helper->getSession()->getCookiePath(),
135-
'domain' => $this->_helper->getSession()->getCookieDomain()
136-
];
137-
138135
return $result;
139136
}
140137

app/code/Magento/Theme/Test/Unit/Model/Wysiwyg/StorageTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ public function testUploadFile()
152152
$this->_helperStorage->expects($this->any())->method('getSession')->will($this->returnValue($session));
153153

154154
$expectedResult = [
155-
'not_empty',
156-
'cookie' => ['name' => null, 'value' => null, 'lifetime' => null, 'path' => null, 'domain' => null],
155+
'not_empty'
157156
];
158157

159158
$this->assertEquals($expectedResult, $this->_storageModel->uploadFile($this->_storageRoot));

dev/tests/integration/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/FileTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function testUploadAction()
3737
],
3838
];
3939

40+
$this->getRequest()->setMethod('POST');
4041
$this->dispatch('backend/admin/downloadable_file/upload/type/samples');
4142
$body = $this->getResponse()->getBody();
4243
$result = Bootstrap::getObjectManager()->get(Json::class)->unserialize($body);
@@ -64,6 +65,7 @@ public function testUploadProhibitedExtensions($fileName)
6465
],
6566
];
6667

68+
$this->getRequest()->setMethod('POST');
6769
$this->dispatch('backend/admin/downloadable_file/upload/type/samples');
6870
$body = $this->getResponse()->getBody();
6971
$result = Bootstrap::getObjectManager()->get(Json::class)->unserialize($body);

0 commit comments

Comments
 (0)