Skip to content

Commit f7d9193

Browse files
authored
Merge branch '2.4-develop' into 13865-safari-block-cookies-breaks-javascript-scripts
2 parents 14112c0 + ba8fae3 commit f7d9193

File tree

149 files changed

+7363
-1661
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+7363
-1661
lines changed

app/code/Magento/Catalog/Block/Rss/Category.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
use Magento\Framework\Exception\NoSuchEntityException;
1111

1212
/**
13-
* Class Category
14-
*
15-
* @package Magento\Catalog\Block\Rss
13+
* Category feed block
1614
*
1715
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1816
*/

app/code/Magento/Catalog/Block/Rss/Product/NewProducts.php

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
use Magento\Framework\App\Rss\DataProviderInterface;
99

1010
/**
11-
* Class NewProducts
12-
* @package Magento\Catalog\Block\Rss\Product
11+
* New products feed block
1312
*/
1413
class NewProducts extends \Magento\Framework\View\Element\AbstractBlock implements DataProviderInterface
1514
{
@@ -55,6 +54,8 @@ public function __construct(
5554
}
5655

5756
/**
57+
* Init
58+
*
5859
* @return void
5960
*/
6061
protected function _construct()
@@ -64,15 +65,15 @@ protected function _construct()
6465
}
6566

6667
/**
67-
* {@inheritdoc}
68+
* @inheritdoc
6869
*/
6970
public function isAllowed()
7071
{
7172
return $this->_scopeConfig->isSetFlag('rss/catalog/new', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
7273
}
7374

7475
/**
75-
* {@inheritdoc}
76+
* @inheritdoc
7677
*/
7778
public function getRssData()
7879
{
@@ -97,10 +98,13 @@ public function getRssData()
9798
$item->setAllowedInRss(true);
9899
$item->setAllowedPriceInRss(true);
99100

100-
$this->_eventManager->dispatch('rss_catalog_new_xml_callback', [
101-
'row' => $item->getData(),
102-
'product' => $item
103-
]);
101+
$this->_eventManager->dispatch(
102+
'rss_catalog_new_xml_callback',
103+
[
104+
'row' => $item->getData(),
105+
'product' => $item
106+
]
107+
);
104108

105109
if (!$item->getAllowedInRss()) {
106110
continue;
@@ -132,6 +136,8 @@ public function getRssData()
132136
}
133137

134138
/**
139+
* Get store id
140+
*
135141
* @return int
136142
*/
137143
protected function getStoreId()
@@ -177,14 +183,16 @@ protected function renderPriceHtml(\Magento\Catalog\Model\Product $product)
177183
}
178184

179185
/**
180-
* {@inheritdoc}
186+
* @inheritdoc
181187
*/
182188
public function getCacheLifetime()
183189
{
184190
return 600;
185191
}
186192

187193
/**
194+
* Get feeds
195+
*
188196
* @return array
189197
*/
190198
public function getFeeds()
@@ -199,7 +207,7 @@ public function getFeeds()
199207
}
200208

201209
/**
202-
* {@inheritdoc}
210+
* @inheritdoc
203211
*/
204212
public function isAuthRequired()
205213
{

app/code/Magento/Catalog/Block/Rss/Product/Special.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
use Magento\Framework\App\Rss\DataProviderInterface;
1010

1111
/**
12-
* Class Special
13-
* @package Magento\Catalog\Block\Rss\Product
12+
* Special products feed block
1413
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1514
*/
1615
class Special extends \Magento\Framework\View\Element\AbstractBlock implements DataProviderInterface
@@ -98,6 +97,8 @@ public function __construct(
9897
}
9998

10099
/**
100+
* Init
101+
*
101102
* @return void
102103
*/
103104
protected function _construct()
@@ -107,6 +108,8 @@ protected function _construct()
107108
}
108109

109110
/**
111+
* Get RSS data
112+
*
110113
* @return array
111114
*/
112115
public function getRssData()
@@ -156,6 +159,8 @@ public function getRssData()
156159
}
157160

158161
/**
162+
* Get entry data
163+
*
159164
* @param \Magento\Catalog\Model\Product $item
160165
* @return array
161166
*/
@@ -245,14 +250,16 @@ public function isAllowed()
245250
}
246251

247252
/**
248-
* {@inheritdoc}
253+
* @inheritdoc
249254
*/
250255
public function getCacheLifetime()
251256
{
252257
return 600;
253258
}
254259

255260
/**
261+
* Get feeds
262+
*
256263
* @return array
257264
*/
258265
public function getFeeds()
@@ -266,7 +273,7 @@ public function getFeeds()
266273
}
267274

268275
/**
269-
* {@inheritdoc}
276+
* @inheritdoc
270277
*/
271278
public function isAuthRequired()
272279
{

app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\Framework\Exception\LocalizedException;
1212

1313
/**
14-
* Class Upload
14+
* Upload product image action controller
1515
*/
1616
class Upload extends \Magento\Backend\App\Action implements HttpPostActionInterface
1717
{

app/code/Magento/Catalog/Helper/Image.php

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
*/
66
namespace Magento\Catalog\Helper;
77

8+
use Magento\Catalog\Model\Config\CatalogMediaConfig;
9+
use Magento\Catalog\Model\View\Asset\PlaceholderFactory;
810
use Magento\Framework\App\Helper\AbstractHelper;
11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\Exception\LocalizedException;
913
use Magento\Framework\View\Element\Block\ArgumentInterface;
1014

1115
/**
12-
* Catalog image helper
16+
* Catalog image helper.
1317
*
1418
* @api
1519
* @SuppressWarnings(PHPMD.TooManyFields)
20+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1621
* @since 100.0.2
1722
*/
1823
class Image extends AbstractHelper implements ArgumentInterface
@@ -40,13 +45,15 @@ class Image extends AbstractHelper implements ArgumentInterface
4045
* Scheduled for rotate image
4146
*
4247
* @var bool
48+
* @deprecated unused
4349
*/
4450
protected $_scheduleRotate = false;
4551

4652
/**
4753
* Angle
4854
*
4955
* @var int
56+
* @deprecated unused
5057
*/
5158
protected $_angle;
5259

@@ -129,31 +136,38 @@ class Image extends AbstractHelper implements ArgumentInterface
129136
protected $attributes = [];
130137

131138
/**
132-
* @var \Magento\Catalog\Model\View\Asset\PlaceholderFactory
139+
* @var PlaceholderFactory
133140
*/
134141
private $viewAssetPlaceholderFactory;
135142

143+
/**
144+
* @var CatalogMediaConfig
145+
*/
146+
private $mediaConfig;
147+
136148
/**
137149
* @param \Magento\Framework\App\Helper\Context $context
138150
* @param \Magento\Catalog\Model\Product\ImageFactory $productImageFactory
139151
* @param \Magento\Framework\View\Asset\Repository $assetRepo
140152
* @param \Magento\Framework\View\ConfigInterface $viewConfig
141-
* @param \Magento\Catalog\Model\View\Asset\PlaceholderFactory $placeholderFactory
153+
* @param PlaceholderFactory $placeholderFactory
154+
* @param CatalogMediaConfig $mediaConfig
142155
*/
143156
public function __construct(
144157
\Magento\Framework\App\Helper\Context $context,
145158
\Magento\Catalog\Model\Product\ImageFactory $productImageFactory,
146159
\Magento\Framework\View\Asset\Repository $assetRepo,
147160
\Magento\Framework\View\ConfigInterface $viewConfig,
148-
\Magento\Catalog\Model\View\Asset\PlaceholderFactory $placeholderFactory = null
161+
PlaceholderFactory $placeholderFactory = null,
162+
CatalogMediaConfig $mediaConfig = null
149163
) {
150164
$this->_productImageFactory = $productImageFactory;
151165
parent::__construct($context);
152166
$this->_assetRepo = $assetRepo;
153167
$this->viewConfig = $viewConfig;
154168
$this->viewAssetPlaceholderFactory = $placeholderFactory
155-
?: \Magento\Framework\App\ObjectManager::getInstance()
156-
->get(\Magento\Catalog\Model\View\Asset\PlaceholderFactory::class);
169+
?: ObjectManager::getInstance()->get(PlaceholderFactory::class);
170+
$this->mediaConfig = $mediaConfig ?: ObjectManager::getInstance()->get(CatalogMediaConfig::class);
157171
}
158172

159173
/**
@@ -382,9 +396,10 @@ public function constrainOnly($flag)
382396
*/
383397
public function backgroundColor($colorRGB)
384398
{
399+
$args = func_get_args();
385400
// assume that 3 params were given instead of array
386401
if (!is_array($colorRGB)) {
387-
$colorRGB = func_get_args();
402+
$colorRGB = $args;
388403
}
389404
$this->_getModel()->setBackgroundColor($colorRGB);
390405
return $this;
@@ -395,6 +410,7 @@ public function backgroundColor($colorRGB)
395410
*
396411
* @param int $angle
397412
* @return $this
413+
* @deprecated unused
398414
*/
399415
public function rotate($angle)
400416
{
@@ -526,7 +542,16 @@ protected function isScheduledActionsAllowed()
526542
public function getUrl()
527543
{
528544
try {
529-
$this->applyScheduledActions();
545+
switch ($this->mediaConfig->getMediaUrlFormat()) {
546+
case CatalogMediaConfig::IMAGE_OPTIMIZATION_PARAMETERS:
547+
$this->initBaseFile();
548+
break;
549+
case CatalogMediaConfig::HASH:
550+
$this->applyScheduledActions();
551+
break;
552+
default:
553+
throw new LocalizedException(__("The specified Catalog media URL format is not supported."));
554+
}
530555
return $this->_getModel()->getUrl();
531556
} catch (\Exception $e) {
532557
return $this->getDefaultPlaceholderUrl();
@@ -595,6 +620,7 @@ protected function _getModel()
595620
*
596621
* @param int $angle
597622
* @return $this
623+
* @deprecated unused
598624
*/
599625
protected function setAngle($angle)
600626
{
@@ -606,6 +632,7 @@ protected function setAngle($angle)
606632
* Get Rotation Angle
607633
*
608634
* @return int
635+
* @deprecated unused
609636
*/
610637
protected function getAngle()
611638
{
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model\Config;
7+
8+
use Magento\Framework\App\Config\ScopeConfigInterface;
9+
10+
/**
11+
* Config for catalog media
12+
*/
13+
class CatalogMediaConfig
14+
{
15+
private const XML_PATH_CATALOG_MEDIA_URL_FORMAT = 'web/url/catalog_media_url_format';
16+
17+
const IMAGE_OPTIMIZATION_PARAMETERS = 'image_optimization_parameters';
18+
const HASH = 'hash';
19+
20+
/**
21+
* @var ScopeConfigInterface
22+
*/
23+
private $scopeConfig;
24+
25+
/**
26+
* Constructor
27+
*
28+
* @param ScopeConfigInterface $scopeConfig
29+
*/
30+
public function __construct(ScopeConfigInterface $scopeConfig)
31+
{
32+
$this->scopeConfig = $scopeConfig;
33+
}
34+
35+
/**
36+
* Get media URL format for catalog images
37+
*
38+
* @param string $scopeType
39+
* @param null|int|string $scopeCode
40+
* @return string
41+
*/
42+
public function getMediaUrlFormat($scopeType = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null)
43+
{
44+
return $this->scopeConfig->getValue(
45+
CatalogMediaConfig::XML_PATH_CATALOG_MEDIA_URL_FORMAT,
46+
$scopeType,
47+
$scopeCode
48+
);
49+
}
50+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Model\Config\Source\Web;
7+
8+
use Magento\Catalog\Model\Config\CatalogMediaConfig;
9+
10+
/**
11+
* Option provider for catalog media URL format system setting.
12+
*/
13+
class CatalogMediaUrlFormat implements \Magento\Framework\Data\OptionSourceInterface
14+
{
15+
/**
16+
* Get a list of supported catalog media URL formats.
17+
*
18+
* @codeCoverageIgnore
19+
*/
20+
public function toOptionArray()
21+
{
22+
return [
23+
[
24+
'value' => CatalogMediaConfig::IMAGE_OPTIMIZATION_PARAMETERS,
25+
'label' => __('Image optimization based on query parameters')
26+
],
27+
['value' => CatalogMediaConfig::HASH, 'label' => __('Unique hash per image variant (Legacy mode)')]
28+
];
29+
}
30+
}

0 commit comments

Comments
 (0)