Skip to content

Commit 372eca4

Browse files
Merge pull request #2924 from magento-qwerty/2.2.6-bugfixes-250718
Fixed issues: - MAGETWO-92175: [Backport for 2.2.x] Wrong product grid behavior in admin panel - MAGETWO-72051: [Backport for 2.2.x] Wrong file upload behavior - MAGETWO-88658: [Backport for 2.2.x] Incorrect category attributes displaying - MAGETWO-93272: [Backport for 2.2.x] Product Video feature not GDPR compliant
2 parents 94eb10f + 9df697d commit 372eca4

File tree

14 files changed

+61
-85
lines changed

14 files changed

+61
-85
lines changed

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@ public function execute()
5454

5555
try {
5656
$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-
];
6557
} catch (\Exception $e) {
6658
$result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
6759
}

app/code/Magento/Catalog/Controller/Adminhtml/Product/MassDelete.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Ui\Component\MassAction\Filter;
1212
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
1313
use Magento\Catalog\Api\ProductRepositoryInterface;
14+
use Magento\Framework\Exception\NotFoundException;
1415

1516
class MassDelete extends \Magento\Catalog\Controller\Adminhtml\Product
1617
{
@@ -54,9 +55,15 @@ public function __construct(
5455

5556
/**
5657
* @return \Magento\Backend\Model\View\Result\Redirect
58+
* @throws NotFoundException
59+
* @throws \Magento\Framework\Exception\LocalizedException
60+
* @throws \Magento\Framework\Exception\StateException
5761
*/
5862
public function execute()
5963
{
64+
if (!$this->getRequest()->isPost()) {
65+
throw new NotFoundException(__('Page not found'));
66+
}
6067
$collection = $this->filter->getCollection($this->collectionFactory->create());
6168
$productDeleted = 0;
6269
/** @var \Magento\Catalog\Model\Product $product */

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

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

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

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
@@ -437,14 +437,7 @@ public function testUploadFile()
437437
$thumbnailDestination = $thumbnailTargetPath . '/' . $fileName;
438438
$type = 'image';
439439
$result = [
440-
'result',
441-
'cookie' => [
442-
'name' => 'session_name',
443-
'value' => '1',
444-
'lifetime' => '50',
445-
'path' => 'cookie/path',
446-
'domain' => 'cookie_domain',
447-
]
440+
'result'
448441
];
449442
$uploader = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Uploader::class)
450443
->disableOriginalConstructor()
@@ -504,17 +497,6 @@ public function testUploadFile()
504497

505498
$this->adapterFactoryMock->expects($this->atLeastOnce())->method('create')->willReturn($image);
506499

507-
$this->sessionMock->expects($this->atLeastOnce())->method('getName')
508-
->willReturn($result['cookie']['name']);
509-
$this->sessionMock->expects($this->atLeastOnce())->method('getSessionId')
510-
->willReturn($result['cookie']['value']);
511-
$this->sessionMock->expects($this->atLeastOnce())->method('getCookieLifetime')
512-
->willReturn($result['cookie']['lifetime']);
513-
$this->sessionMock->expects($this->atLeastOnce())->method('getCookiePath')
514-
->willReturn($result['cookie']['path']);
515-
$this->sessionMock->expects($this->atLeastOnce())->method('getCookieDomain')
516-
->willReturn($result['cookie']['domain']);
517-
518500
$this->assertEquals($result, $this->imagesStorage->uploadFile($targetPath, $type));
519501
}
520502
}

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,6 @@ public function execute()
9696
$relativePath = rtrim($tmpPath, '/') . '/' . ltrim($result['file'], '/');
9797
$this->storageDatabase->saveFile($relativePath);
9898
}
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-
];
10799
} catch (\Exception $e) {
108100
$result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
109101
}

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/ProductVideo/view/adminhtml/web/js/get-video-information.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ define([
8686
this._height = this.element.data('height');
8787
this._autoplay = !!this.element.data('autoplay');
8888
this._playing = this._autoplay || false;
89+
this.useYoutubeNocookie = this.element.data('youtubenocookie') || false;
8990

9091
this._responsive = this.element.data('responsive') !== false;
9192

@@ -163,6 +164,12 @@ define([
163164
* @private
164165
*/
165166
'youtubeapiready': function () {
167+
var host = 'https://www.youtube.com';
168+
169+
if (self.useYoutubeNocookie) {
170+
host = 'https://www.youtube-nocookie.com';
171+
}
172+
166173
if (self._player !== undefined) {
167174
return;
168175
}
@@ -177,6 +184,7 @@ define([
177184
width: self._width,
178185
videoId: self._code,
179186
playerVars: self._params,
187+
host: host,
180188
events: {
181189

182190
/**
@@ -469,7 +477,8 @@ define([
469477
description: tmp.snippet.description,
470478
thumbnail: tmp.snippet.thumbnails.high.url,
471479
videoId: videoInfo.id,
472-
videoProvider: videoInfo.type
480+
videoProvider: videoInfo.type,
481+
useYoutubeNocookie: videoInfo.useYoutubeNocookie
473482
};
474483
this._videoInformation = respData;
475484
this.element.trigger(this._UPDATE_VIDEO_INFORMATION_TRIGGER, respData);
@@ -600,7 +609,8 @@ define([
600609
var id,
601610
type,
602611
ampersandPosition,
603-
vimeoRegex;
612+
vimeoRegex,
613+
useYoutubeNocookie = false;
604614

605615
if (typeof href !== 'string') {
606616
return href;
@@ -620,9 +630,13 @@ define([
620630
id = id.substring(0, ampersandPosition);
621631
}
622632

623-
} else if (href.host.match(/youtube\.com|youtu\.be/)) {
633+
} else if (href.host.match(/youtube\.com|youtu\.be|youtube-nocookie.com/)) {
624634
id = href.pathname.replace(/^\/(embed\/|v\/)?/, '').replace(/\/.*/, '');
625635
type = 'youtube';
636+
637+
if (href.host.match(/youtube-nocookie.com/)) {
638+
useYoutubeNocookie = true;
639+
}
626640
} else if (href.host.match(/vimeo\.com/)) {
627641
type = 'vimeo';
628642
vimeoRegex = new RegExp(['https?:\\/\\/(?:www\\.|player\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)',
@@ -640,7 +654,7 @@ define([
640654
}
641655

642656
return id ? {
643-
id: id, type: type, s: href.search.replace(/^\?/, '')
657+
id: id, type: type, s: href.search.replace(/^\?/, ''), useYoutubeNocookie: useYoutubeNocookie
644658
} : false;
645659
}
646660
});

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ define([
2121
container: '.video-player-container',
2222
videoClass: 'product-video',
2323
reset: false,
24+
useYoutubeNocookie: false,
2425
metaData: {
2526
DOM: {
2627
title: '.video-information.title span',
@@ -90,13 +91,17 @@ define([
9091
uploaderLink;
9192

9293
this.reset();
93-
this.element.find(this.options.container).append('<div class="' +
94-
this.options.videoClass +
95-
'" data-type="' +
96-
this.options.videoProvider +
97-
'" data-code="' +
98-
this.options.videoId +
99-
'" data-width="100%" data-height="100%"></div>');
94+
this.element.find(this.options.container).append(
95+
'<div class="' +
96+
this.options.videoClass +
97+
'" data-type="' +
98+
this.options.videoProvider +
99+
'" data-code="' +
100+
this.options.videoId +
101+
'" data-youtubenocookie="' +
102+
this.options.useYoutubeNocookie +
103+
'" data-width="100%" data-height="100%"></div>'
104+
);
100105
this.element.find(this.options.metaData.DOM.wrapper).show();
101106
this.element.find(this.options.metaData.DOM.title).text(this.options.metaData.data.title);
102107
this.element.find(this.options.metaData.DOM.uploaded).text(this.options.metaData.data.uploaded);
@@ -335,6 +340,7 @@ define([
335340
.createVideoPlayer({
336341
videoId: data.videoId,
337342
videoProvider: data.videoProvider,
343+
useYoutubeNocookie: data.useYoutubeNocookie,
338344
reset: false,
339345
metaData: {
340346
DOM: {

app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ define([
3434
var id,
3535
type,
3636
ampersandPosition,
37-
vimeoRegex;
37+
vimeoRegex,
38+
useYoutubeNocookie = false;
3839

3940
/**
4041
* Get youtube ID
@@ -68,9 +69,13 @@ define([
6869
id = _getYoutubeId(id);
6970
type = 'youtube';
7071
}
71-
} else if (href.host.match(/youtube\.com|youtu\.be/)) {
72+
} else if (href.host.match(/youtube\.com|youtu\.be|youtube-nocookie.com/)) {
7273
id = href.pathname.replace(/^\/(embed\/|v\/)?/, '').replace(/\/.*/, '');
7374
type = 'youtube';
75+
76+
if (href.host.match(/youtube-nocookie.com/)) {
77+
useYoutubeNocookie = true;
78+
}
7479
} else if (href.host.match(/vimeo\.com/)) {
7580
type = 'vimeo';
7681
vimeoRegex = new RegExp(['https?:\\/\\/(?:www\\.|player\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)',
@@ -85,7 +90,7 @@ define([
8590
}
8691

8792
return id ? {
88-
id: id, type: type, s: href.search.replace(/^\?/, '')
93+
id: id, type: type, s: href.search.replace(/^\?/, ''), useYoutubeNocookie: useYoutubeNocookie
8994
} : false;
9095
}
9196

@@ -283,6 +288,7 @@ define([
283288
tmpVideoData.id = dataUrl.id;
284289
tmpVideoData.provider = dataUrl.type;
285290
tmpVideoData.videoUrl = tmpInputData.videoUrl;
291+
tmpVideoData.useYoutubeNocookie = dataUrl.useYoutubeNocookie;
286292
}
287293

288294
videoData.push(tmpVideoData);
@@ -631,6 +637,8 @@ define([
631637
videoData.provider +
632638
'" data-code="' +
633639
videoData.id +
640+
'" data-youtubenocookie="' +
641+
videoData.useYoutubeNocookie +
634642
'" data-width="100%" data-height="100%"></div>'
635643
);
636644
},

app/code/Magento/ProductVideo/view/frontend/web/js/load-player.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ define(['jquery', 'jquery/ui'], function ($) {
8888
this._playing = this._autoplay || false;
8989
this._loop = this.element.data('loop');
9090
this._rel = this.element.data('related');
91+
this.useYoutubeNocookie = this.element.data('youtubenocookie') || false;
9192

9293
this._responsive = this.element.data('responsive') !== false;
9394

@@ -164,6 +165,12 @@ define(['jquery', 'jquery/ui'], function ($) {
164165
* Handle event
165166
*/
166167
'youtubeapiready': function () {
168+
var host = 'https://www.youtube.com';
169+
170+
if (self.useYoutubeNocookie) {
171+
host = 'https://www.youtube-nocookie.com';
172+
}
173+
167174
if (self._player !== undefined) {
168175
return;
169176
}
@@ -182,6 +189,7 @@ define(['jquery', 'jquery/ui'], function ($) {
182189
width: self._width,
183190
videoId: self._code,
184191
playerVars: self._params,
192+
host: host,
185193
events: {
186194

187195
/**

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,6 @@ public function uploadFile($targetPath)
127127

128128
$this->_createThumbnail($targetPath . '/' . $uploader->getUploadedFileName());
129129

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-
138130
return $result;
139131
}
140132

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));

app/code/Magento/Widget/Block/Adminhtml/Widget/Chooser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ protected function _toHtml()
180180
<label class="widget-option-label" id="' .
181181
$chooserId .
182182
'label">' .
183-
($this->getLabel() ? $this->getLabel() : __(
183+
($this->getLabel() ? $this->escapeHtml($this->getLabel()) : __(
184184
'Not Selected'
185185
)) .
186186
'</label>

lib/web/fotorama/fotorama.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ fotoramaVersion = '4.6.4';
831831
}
832832
type = 'youtube';
833833
}
834-
} else if (href.host.match(/youtube\.com|youtu\.be/)) {
834+
} else if (href.host.match(/youtube\.com|youtu\.be|youtube-nocookie.com/)) {
835835
id = href.pathname.replace(/^\/(embed\/|v\/)?/, '').replace(/\/.*/, '');
836836
type = 'youtube';
837837
} else if (href.host.match(/vimeo\.com/)) {

0 commit comments

Comments
 (0)