Skip to content

Commit b8a8c15

Browse files
Merge branch '2.4-develop' into arrows_pr_18082022
2 parents ceb0998 + 5dd75c7 commit b8a8c15

File tree

274 files changed

+5107
-2134
lines changed

Some content is hidden

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

274 files changed

+5107
-2134
lines changed

app/code/Magento/AdminNotification/Model/Feed.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\AdminNotification\Model;
77

8+
use Laminas\Http\Request;
89
use Magento\AdminNotification\Model\InboxFactory;
910
use Magento\Backend\App\ConfigInterface;
1011
use Magento\Framework\App\DeploymentConfig;
@@ -227,7 +228,7 @@ public function getFeedData()
227228
{
228229
/** @var Curl $curl */
229230
$curl = $this->curlFactory->create();
230-
$curl->setConfig(
231+
$curl->setOptions(
231232
[
232233
'timeout' => 2,
233234
'useragent' => $this->productMetadata->getName()
@@ -236,7 +237,7 @@ public function getFeedData()
236237
'referer' => $this->urlBuilder->getUrl('*/*/*')
237238
]
238239
);
239-
$curl->write(\Zend_Http_Client::GET, $this->getFeedUrl(), '1.0');
240+
$curl->write(Request::METHOD_GET, $this->getFeedUrl(), '1.0');
240241
$data = $curl->read();
241242
$data = preg_split('/^\r?$/m', $data, 2);
242243
$data = trim($data[1] ?? '');

app/code/Magento/AdminNotification/Model/System/Message/Security.php

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,28 @@
66

77
namespace Magento\AdminNotification\Model\System\Message;
88

9+
use Laminas\Http\Request;
10+
use Laminas\Http\Response;
11+
use Magento\Backend\App\ConfigInterface;
12+
use Magento\Framework\App\CacheInterface;
13+
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
use Magento\Framework\HTTP\Adapter\Curl;
15+
use Magento\Framework\HTTP\Adapter\CurlFactory;
16+
use Magento\Framework\Notification\MessageInterface;
17+
use Magento\Framework\Phrase;
918
use Magento\Store\Model\Store;
19+
use Throwable;
1020

1121
/**
1222
* @api
1323
* @since 100.0.2
1424
*/
15-
class Security implements \Magento\Framework\Notification\MessageInterface
25+
class Security implements MessageInterface
1626
{
1727
/**
1828
* Cache key for saving verification result
1929
*/
20-
const VERIFICATION_RESULT_CACHE_KEY = 'configuration_files_access_level_verification';
30+
public const VERIFICATION_RESULT_CACHE_KEY = 'configuration_files_access_level_verification';
2131

2232
/**
2333
* File path for verification
@@ -34,36 +44,36 @@ class Security implements \Magento\Framework\Notification\MessageInterface
3444
private $_verificationTimeOut = 2;
3545

3646
/**
37-
* @var \Magento\Framework\App\CacheInterface
47+
* @var CacheInterface
3848
*/
3949
protected $_cache;
4050

4151
/**
42-
* @var \Magento\Backend\App\ConfigInterface
52+
* @var ConfigInterface
4353
*/
4454
protected $_backendConfig;
4555

4656
/**
47-
* @var \Magento\Framework\App\Config\ScopeConfigInterface
57+
* @var ScopeConfigInterface
4858
*/
4959
protected $_config;
5060

5161
/**
52-
* @var \Magento\Framework\HTTP\Adapter\CurlFactory
62+
* @var CurlFactory
5363
*/
5464
protected $_curlFactory;
5565

5666
/**
57-
* @param \Magento\Framework\App\CacheInterface $cache
58-
* @param \Magento\Backend\App\ConfigInterface $backendConfig
59-
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
60-
* @param \Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory
67+
* @param CacheInterface $cache
68+
* @param ConfigInterface $backendConfig
69+
* @param ScopeConfigInterface $config
70+
* @param CurlFactory $curlFactory
6171
*/
6272
public function __construct(
63-
\Magento\Framework\App\CacheInterface $cache,
64-
\Magento\Backend\App\ConfigInterface $backendConfig,
65-
\Magento\Framework\App\Config\ScopeConfigInterface $config,
66-
\Magento\Framework\HTTP\Adapter\CurlFactory $curlFactory
73+
CacheInterface $cache,
74+
ConfigInterface $backendConfig,
75+
ScopeConfigInterface $config,
76+
CurlFactory $curlFactory
6777
) {
6878
$this->_cache = $cache;
6979
$this->_backendConfig = $backendConfig;
@@ -100,12 +110,12 @@ private function _isFileAccessible()
100110
{
101111
$unsecureBaseURL = $this->_config->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default');
102112

103-
/** @var $http \Magento\Framework\HTTP\Adapter\Curl */
113+
/** @var $http Curl */
104114
$http = $this->_curlFactory->create();
105-
$http->setConfig(['timeout' => $this->_verificationTimeOut]);
106-
$http->write(\Zend_Http_Client::POST, $unsecureBaseURL . $this->_filePath);
115+
$http->setOptions(['timeout' => $this->_verificationTimeOut]);
116+
$http->write(Request::METHOD_POST, $unsecureBaseURL . $this->_filePath);
107117
$responseBody = $http->read();
108-
$responseCode = \Zend_Http_Response::extractCode($responseBody);
118+
$responseCode = $this->extractCodeFromResponse($responseBody);
109119
$http->close();
110120

111121
return $responseCode == 200;
@@ -134,7 +144,7 @@ public function isDisplayed()
134144
/**
135145
* Retrieve message text
136146
*
137-
* @return \Magento\Framework\Phrase
147+
* @return Phrase
138148
*/
139149
public function getText()
140150
{
@@ -151,6 +161,24 @@ public function getText()
151161
*/
152162
public function getSeverity()
153163
{
154-
return \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL;
164+
return MessageInterface::SEVERITY_CRITICAL;
165+
}
166+
167+
/**
168+
* Extract the response code from a response string
169+
*
170+
* @param string $responseString
171+
*
172+
* @return false|int
173+
*/
174+
private function extractCodeFromResponse(string $responseString)
175+
{
176+
try {
177+
$responseCode = Response::fromString($responseString)->getStatusCode();
178+
} catch (Throwable $e) {
179+
$responseCode = false;
180+
}
181+
182+
return $responseCode;
155183
}
156184
}

app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function testCheckUpdate(bool $callInbox, string $curlRequest): void
173173
$this->curlFactory
174174
->method('create')
175175
->willReturn($this->curl);
176-
$this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
176+
$this->curl->expects($this->once())->method('setOptions')->with($configValues)->willReturnSelf();
177177
$this->curl->expects($this->once())->method('read')->willReturn($curlRequest);
178178
$this->backendConfig->expects($this->once())->method('isSetFlag')->willReturn(false);
179179
$this->backendConfig

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
*/
2222
class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
2323
{
24-
const VALUE_ALL_GROUPS = 'ALL GROUPS';
25-
const VALUE_ALL_WEBSITES = 'All Websites';
26-
const COL_SKU = 'sku';
27-
const COL_TIER_PRICE_WEBSITE = 'tier_price_website';
28-
const COL_TIER_PRICE_CUSTOMER_GROUP = 'tier_price_customer_group';
29-
const COL_TIER_PRICE_QTY = 'tier_price_qty';
30-
const COL_TIER_PRICE = 'tier_price';
31-
const COL_TIER_PRICE_PERCENTAGE_VALUE = 'percentage_value';
32-
const COL_TIER_PRICE_TYPE = 'tier_price_value_type';
33-
const TIER_PRICE_TYPE_FIXED = 'Fixed';
34-
const TIER_PRICE_TYPE_PERCENT = 'Discount';
35-
const TABLE_TIER_PRICE = 'catalog_product_entity_tier_price';
36-
const DEFAULT_ALL_GROUPS_GROUPED_PRICE_VALUE = '0';
37-
const ENTITY_TYPE_CODE = 'advanced_pricing';
38-
const VALIDATOR_MAIN = 'validator';
39-
const VALIDATOR_WEBSITE = 'validator_website';
24+
public const VALUE_ALL_GROUPS = 'ALL GROUPS';
25+
public const VALUE_ALL_WEBSITES = 'All Websites';
26+
public const COL_SKU = 'sku';
27+
public const COL_TIER_PRICE_WEBSITE = 'tier_price_website';
28+
public const COL_TIER_PRICE_CUSTOMER_GROUP = 'tier_price_customer_group';
29+
public const COL_TIER_PRICE_QTY = 'tier_price_qty';
30+
public const COL_TIER_PRICE = 'tier_price';
31+
public const COL_TIER_PRICE_PERCENTAGE_VALUE = 'percentage_value';
32+
public const COL_TIER_PRICE_TYPE = 'tier_price_value_type';
33+
public const TIER_PRICE_TYPE_FIXED = 'Fixed';
34+
public const TIER_PRICE_TYPE_PERCENT = 'Discount';
35+
public const TABLE_TIER_PRICE = 'catalog_product_entity_tier_price';
36+
public const DEFAULT_ALL_GROUPS_GROUPED_PRICE_VALUE = '0';
37+
public const ENTITY_TYPE_CODE = 'advanced_pricing';
38+
public const VALIDATOR_MAIN = 'validator';
39+
public const VALIDATOR_WEBSITE = 'validator_website';
4040

4141
/**
4242
* @deprecated
@@ -76,9 +76,7 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
7676
protected $needColumnCheck = true;
7777

7878
/**
79-
* Valid column names.
80-
*
81-
* @array
79+
* @var array
8280
*/
8381
protected $validColumnNames = [
8482
self::COL_SKU,
@@ -144,8 +142,6 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
144142
protected $_permanentAttributes = [self::COL_SKU];
145143

146144
/**
147-
* Catalog product entity
148-
*
149145
* @var string
150146
*/
151147
protected $_catalogProductEntity;
@@ -156,8 +152,6 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
156152
protected $dateTime;
157153

158154
/**
159-
* Product entity link field
160-
*
161155
* @var string
162156
*/
163157
private $productEntityLinkField;
@@ -272,7 +266,6 @@ public function getEntityTypeCode()
272266
* @param array $rowData
273267
* @param int $rowNum
274268
* @return bool
275-
* @throws \Zend_Validate_Exception
276269
*/
277270
public function validateRow(array $rowData, $rowNum)
278271
{

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing/Validator.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing;
77

88
use Magento\CatalogImportExport\Model\Import\Product\RowValidatorInterface;
9-
use \Magento\Framework\Validator\AbstractValidator;
9+
use Magento\Framework\Validator\AbstractValidator;
1010

1111
class Validator extends AbstractValidator implements RowValidatorInterface
1212
{
@@ -28,7 +28,6 @@ public function __construct($validators = [])
2828
*
2929
* @param array $value
3030
* @return bool
31-
* @throws \Zend_Validate_Exception
3231
*/
3332
public function isValid($value)
3433
{
@@ -44,8 +43,7 @@ public function isValid($value)
4443
}
4544

4645
/**
47-
* @param \Magento\CatalogImportExport\Model\Import\Product $context
48-
* @return $this
46+
* @inheritdoc
4947
*/
5048
public function init($context)
5149
{

app/code/Magento/Analytics/Model/Connector/Http/Client/Curl.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Analytics\Model\Connector\Http\Client;
77

8+
use Laminas\Http\Response;
89
use Magento\Analytics\Model\Connector\Http\ConverterInterface;
910
use Psr\Log\LoggerInterface;
1011
use Magento\Framework\HTTP\Adapter\CurlFactory;
@@ -56,11 +57,12 @@ public function __construct(
5657
}
5758

5859
/**
59-
* {@inheritdoc}
60+
* @inheritdoc
6061
*/
6162
public function request($method, $url, array $body = [], array $headers = [], $version = '1.1')
6263
{
63-
$response = new \Zend_Http_Response(0, []);
64+
$response = new Response();
65+
$response->setCustomStatusCode(Response::STATUS_CODE_CUSTOM);
6466

6567
try {
6668
$curl = $this->curlFactory->create();
@@ -93,6 +95,8 @@ public function request($method, $url, array $body = [], array $headers = [], $v
9395
}
9496

9597
/**
98+
* Apply content type header from converter
99+
*
96100
* @param array $headers
97101
*
98102
* @return array

app/code/Magento/Analytics/Model/Connector/Http/ClientInterface.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
*/
66
namespace Magento\Analytics\Model\Connector\Http;
77

8+
use Laminas\Http\Response;
9+
810
/**
911
* An interface for an HTTP client.
1012
*
11-
* Sends requests via a proper adapter.
13+
* Send requests via a proper adapter.
1214
*/
1315
interface ClientInterface
1416
{
@@ -23,7 +25,7 @@ interface ClientInterface
2325
* @param array $headers
2426
* @param string $version
2527
*
26-
* @return \Zend_Http_Response
28+
* @return Response
2729
*/
2830
public function request($method, $url, array $body = [], array $headers = [], $version = '1.1');
2931
}

app/code/Magento/Analytics/Model/Connector/Http/ResponseResolver.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Analytics\Model\Connector\Http;
77

8+
use Laminas\Http\Response;
9+
810
/**
911
* Extract result from http response. Call response handler by status.
1012
*/
@@ -13,12 +15,12 @@ class ResponseResolver
1315
/**
1416
* @var ConverterInterface
1517
*/
16-
private $converter;
18+
private ConverterInterface $converter;
1719

1820
/**
1921
* @var array
2022
*/
21-
private $responseHandlers;
23+
private array $responseHandlers;
2224

2325
/**
2426
* @param ConverterInterface $converter
@@ -33,24 +35,27 @@ public function __construct(ConverterInterface $converter, array $responseHandle
3335
/**
3436
* Get result from $response.
3537
*
36-
* @param \Zend_Http_Response $response
38+
* @param Response $response
3739
* @return bool|string
3840
*/
39-
public function getResult(\Zend_Http_Response $response)
41+
public function getResult(Response $response)
4042
{
4143
$result = false;
4244
$converterMediaType = $this->converter->getContentMediaType();
4345

4446
/** Content-Type header may not only contain media-type declaration */
45-
if ($response->getBody()
46-
&& is_int(strripos($response->getHeader('Content-Type'), (string) $converterMediaType))) {
47-
$responseBody = $this->converter->fromBody($response->getBody());
47+
$responseBody = $response->getBody();
48+
$contentType = $response->getHeaders()->has('Content-Type') ?
49+
$response->getHeaders()->get('Content-Type')->getFieldValue() :
50+
'';
51+
if ($responseBody && is_int(strripos($contentType, $converterMediaType))) {
52+
$responseBody = $this->converter->fromBody($responseBody);
4853
} else {
4954
$responseBody = [];
5055
}
5156

52-
if (array_key_exists($response->getStatus(), $this->responseHandlers)) {
53-
$result = $this->responseHandlers[$response->getStatus()]->handleResponse($responseBody);
57+
if (array_key_exists($response->getStatusCode(), $this->responseHandlers)) {
58+
$result = $this->responseHandlers[$response->getStatusCode()]->handleResponse($responseBody);
5459
}
5560

5661
return $result;

0 commit comments

Comments
 (0)