Skip to content

Commit 1852609

Browse files
authored
Merge branch '2.4.4-develop' into cia-2.4.4-develop-bugfixes-04112021
2 parents ea12e80 + 53231ba commit 1852609

File tree

55 files changed

+810
-226
lines changed

Some content is hidden

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

55 files changed

+810
-226
lines changed

app/code/Magento/CatalogInventory/Model/StockStateProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function checkQuoteItemQty(StockItemInterface $stockItem, $qty, $summaryQ
135135
$result->addData($this->checkQtyIncrements($stockItem, $qty)->getData());
136136

137137
$result->setItemIsQtyDecimal($stockItem->getIsQtyDecimal());
138-
if (!$stockItem->getIsQtyDecimal() && (floor($qty) !== $qty)) {
138+
if (!$stockItem->getIsQtyDecimal() && (floor($qty) !== (float) $qty)) {
139139
$result->setHasError(true)
140140
->setMessage(__('You cannot use decimal quantity for this product.'))
141141
->setErrorCode('qty_decimal')

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ class Storage extends \Magento\Framework\DataObject
7777
protected $_coreFileStorageDb = null;
7878

7979
/**
80-
* Cms wysiwyg images
81-
*
8280
* @var \Magento\Cms\Helper\Wysiwyg\Images
8381
*/
8482
protected $_cmsWysiwygImages = null;
@@ -109,36 +107,26 @@ class Storage extends \Magento\Framework\DataObject
109107
protected $_session;
110108

111109
/**
112-
* Directory database factory
113-
*
114110
* @var \Magento\MediaStorage\Model\File\Storage\Directory\DatabaseFactory
115111
*/
116112
protected $_directoryDatabaseFactory;
117113

118114
/**
119-
* Storage database factory
120-
*
121115
* @var \Magento\MediaStorage\Model\File\Storage\DatabaseFactory
122116
*/
123117
protected $_storageDatabaseFactory;
124118

125119
/**
126-
* Storage file factory
127-
*
128120
* @var \Magento\MediaStorage\Model\File\Storage\FileFactory
129121
*/
130122
protected $_storageFileFactory;
131123

132124
/**
133-
* Storage collection factory
134-
*
135125
* @var \Magento\Cms\Model\Wysiwyg\Images\Storage\CollectionFactory
136126
*/
137127
protected $_storageCollectionFactory;
138128

139129
/**
140-
* Uploader factory
141-
*
142130
* @var \Magento\MediaStorage\Model\File\UploaderFactory
143131
*/
144132
protected $_uploaderFactory;
@@ -745,8 +733,8 @@ private function getResizedParams(string $source): array
745733
$configWidth = $this->_resizeParameters['width'];
746734
$configHeight = $this->_resizeParameters['height'];
747735

748-
//phpcs:ignore Generic.PHP.NoSilencedErrors
749-
[$imageWidth, $imageHeight] = @getimagesize($source);
736+
$driver = $this->_directory->getDriver();
737+
[$imageWidth, $imageHeight] = getimagesizefromstring($driver->fileGetContents($source));
750738

751739
if ($imageWidth && $imageHeight) {
752740
$imageWidth = $configWidth > $imageWidth ? $imageWidth : $configWidth;
@@ -999,7 +987,7 @@ private function getAllowedPathPattern()
999987
);
1000988
$regExp = '/^(';
1001989
$or = '';
1002-
foreach($mediaGalleryImageFolders as $folder) {
990+
foreach ($mediaGalleryImageFolders as $folder) {
1003991
$folderPattern = str_replace('/', '[\/]+', $folder);
1004992
$regExp .= $or . $folderPattern . '\b(?!-)(?:\/?[a-zA-Z0-9\-\_]+)*\/?$';
1005993
$or = '|';
@@ -1013,7 +1001,7 @@ private function getAllowedPathPattern()
10131001
/**
10141002
* Get allowed media gallery image folders
10151003
*
1016-
* example:
1004+
* Example:
10171005
* [
10181006
* [0 => 'wysiwyg'],
10191007
* [0 => 'catalog', 1 => 'category']

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ class StorageTest extends TestCase
141141
*/
142142
private $fileMock;
143143

144+
/**
145+
* @var array
146+
*/
144147
private $allowedImageExtensions = [
145148
'jpg' => 'image/jpg',
146149
'jpeg' => 'image/jpeg',
@@ -366,13 +369,13 @@ public function testGetDirsCollectionCreateSubDirectories()
366369
}
367370

368371
/**
369-
* @param array $exclude
370-
* @param array $include
371-
* @param array $fileNames
372-
* @param array $expectedRemoveKeys
372+
* @param $path
373+
* @param $callNum
374+
* @param string $dirsFilter
375+
* @throws \Exception
373376
* @dataProvider dirsCollectionDataProvider
374377
*/
375-
public function testGetDirsCollection($path, $callNum, $dirsFilter='')
378+
public function testGetDirsCollection($path, $callNum, $dirsFilter = '')
376379
{
377380
$this->generalTestGetDirsCollection($path, $callNum, $dirsFilter);
378381
}
@@ -517,6 +520,9 @@ public function testUploadFile()
517520
[$thumbnailTargetPath, true],
518521
]
519522
);
523+
$this->driverMock->expects(self::once())
524+
->method('fileGetContents')
525+
->willReturn('some content');
520526

521527
$image = $this->getMockBuilder(Image::class)
522528
->disableOriginalConstructor()

app/code/Magento/Paypal/Block/PayLater/Banner.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Magento\Framework\View\Element\Template;
1212
use Magento\Paypal\Model\PayLaterConfig;
1313
use Magento\Paypal\Model\SdkUrl;
14+
use Magento\Paypal\Model\Config as PaypalConfig;
15+
use Magento\Framework\App\ObjectManager;
1416

1517
/**
1618
* PayPal PayLater component block
@@ -38,23 +40,32 @@ class Banner extends Template
3840
*/
3941
private $position = '';
4042

43+
/**
44+
* @var PaypalConfig
45+
*/
46+
private $paypalConfig;
47+
4148
/**
4249
* @param Template\Context $context
4350
* @param PayLaterConfig $payLaterConfig
4451
* @param SdkUrl $sdkUrl
4552
* @param array $data
53+
* @param PaypalConfig $paypalConfig
4654
*/
4755
public function __construct(
4856
Template\Context $context,
4957
PayLaterConfig $payLaterConfig,
5058
SdkUrl $sdkUrl,
51-
array $data = []
59+
array $data = [],
60+
PaypalConfig $paypalConfig = null
5261
) {
5362
parent::__construct($context, $data);
5463
$this->payLaterConfig = $payLaterConfig;
5564
$this->sdkUrl = $sdkUrl;
5665
$this->placement = $data['placement'] ?? '';
5766
$this->position = $data['position'] ?? '';
67+
$this->paypalConfig = $paypalConfig ?: ObjectManager::getInstance()
68+
->get(PaypalConfig::class);
5869
}
5970

6071
/**
@@ -85,6 +96,9 @@ public function getJsLayout()
8596
$displayAmount = $config['displayAmount'] ?? false;
8697
$config['displayAmount'] = !$displayAmount || $this->payLaterConfig->isPPBillingAgreementEnabled()
8798
? false : true;
99+
$config['dataAttributes'] = [
100+
'data-partner-attribution-id' => $this->paypalConfig->getBuildNotationCode()
101+
];
88102

89103
//Extend block component attributes with defaults
90104
$componentAttributes = $this->jsLayout['components']['payLater']['config']['attributes'] ?? [];

app/code/Magento/Paypal/Block/PayLater/LayoutProcessor.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
namespace Magento\Paypal\Block\PayLater;
1010

1111
use Magento\Checkout\Block\Checkout\LayoutProcessorInterface;
12+
use Magento\Framework\App\ObjectManager;
1213
use Magento\Paypal\Model\PayLaterConfig;
1314
use Magento\Paypal\Model\SdkUrl;
15+
use Magento\Paypal\Model\Config as PaypalConfig;
1416

1517
/**
1618
* PayLater Layout Processor
@@ -32,25 +34,35 @@ class LayoutProcessor implements LayoutProcessorInterface
3234
*/
3335
private $sdkUrl;
3436

37+
/**
38+
* @var PaypalConfig
39+
*/
40+
private $paypalConfig;
41+
3542
/**
3643
* @param PayLaterConfig $payLaterConfig
3744
* @param SdkUrl $sdkUrl
45+
* @param PaypalConfig $paypalConfig
3846
*/
39-
public function __construct(PayLaterConfig $payLaterConfig, SdkUrl $sdkUrl)
40-
{
47+
public function __construct(
48+
PayLaterConfig $payLaterConfig,
49+
SdkUrl $sdkUrl,
50+
PaypalConfig $paypalConfig
51+
) {
4152
$this->payLaterConfig = $payLaterConfig;
4253
$this->sdkUrl = $sdkUrl;
54+
$this->paypalConfig = $paypalConfig;
4355
}
4456

4557
/**
46-
* {@inheritdoc}
58+
* @inheritdoc
4759
*/
4860
public function process($jsLayout)
4961
{
5062
if (!$this->payLaterConfig->isEnabled(PayLaterConfig::CHECKOUT_PAYMENT_PLACEMENT)) {
5163
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']
52-
['children']['payment']['children']['payments-list']['children']['paypal-method-extra-content']['children']
53-
['paylater-place-order']);
64+
['children']['payment']['children']['payments-list']['children']['paypal-method-extra-content']
65+
['children']['paylater-place-order']);
5466

5567
return $jsLayout;
5668
}
@@ -75,6 +87,9 @@ public function process($jsLayout)
7587
$displayAmount = $config['displayAmount'] ?? false;
7688
$config['displayAmount'] = !$displayAmount || $this->payLaterConfig->isPPBillingAgreementEnabled()
7789
? false : true;
90+
$config['dataAttributes'] = [
91+
'data-partner-attribution-id' => $this->paypalConfig->getBuildNotationCode()
92+
];
7893

7994
$attributes = $this->payLaterConfig->getSectionConfig(
8095
PayLaterConfig::CHECKOUT_PAYMENT_PLACEMENT,

app/code/Magento/Paypal/Model/Config.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* Config model that is aware of all \Magento\Paypal payment methods
1313
*
1414
* Works with PayPal-specific system configuration
15-
1615
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
1716
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
1817
*/
@@ -180,7 +179,6 @@ class Config extends AbstractConfig
180179
const PAYLATER = 'paypal_paylater';
181180

182181
/**
183-
* Instructions for generating proper BN code
184182
*
185183
* @var array
186184
*/
@@ -191,7 +189,6 @@ class Config extends AbstractConfig
191189
];
192190

193191
/**
194-
* Style system config map (Express Checkout)
195192
*
196193
* @var array
197194
*/
@@ -204,7 +201,6 @@ class Config extends AbstractConfig
204201
];
205202

206203
/**
207-
* Currency codes supported by PayPal methods
208204
*
209205
* @var string[]
210206
*/
@@ -234,7 +230,6 @@ class Config extends AbstractConfig
234230
];
235231

236232
/**
237-
* Merchant country supported by PayPal
238233
*
239234
* @var string[]
240235
*/
@@ -310,7 +305,6 @@ class Config extends AbstractConfig
310305
];
311306

312307
/**
313-
* Buyer country supported by PayPal
314308
*
315309
* @var string[]
316310
*/
@@ -837,10 +831,10 @@ public function getCountryMethods($countryCode = null)
837831
* @param string $token
838832
* @return string
839833
*/
840-
public function getPayPalBasicStartUrl($token)
834+
public function getPayPalBasicStartUrl($token): string
841835
{
842836
$params = [
843-
'cmd' => '_express-checkout',
837+
'cmd' => '_express-checkout',
844838
'token' => $token,
845839
];
846840

@@ -1519,6 +1513,7 @@ protected function _mapExpressFieldset($fieldName)
15191513
case 'merchant_id':
15201514
case 'client_id':
15211515
case 'sandbox_client_id':
1516+
case 'buyer_country':
15221517
case 'supported_locales':
15231518
case 'smart_buttons_supported_locales':
15241519
return "payment/{$this->_methodCode}/{$fieldName}";
@@ -1591,6 +1586,7 @@ protected function _mapWppFieldset($fieldName)
15911586
case 'api_signature':
15921587
case 'api_cert':
15931588
case 'sandbox_flag':
1589+
case 'buyer_country':
15941590
case 'use_proxy':
15951591
case 'proxy_host':
15961592
case 'proxy_port':
@@ -1631,6 +1627,7 @@ protected function _mapWpukFieldset($fieldName)
16311627
case 'vendor':
16321628
case 'pwd':
16331629
case 'sandbox_flag':
1630+
case 'buyer_country':
16341631
case 'use_proxy':
16351632
case 'proxy_host':
16361633
case 'proxy_port':

0 commit comments

Comments
 (0)