Skip to content

Commit 9e1b12f

Browse files
Merge pull request #22 from magento/develop
Back-port develop into 1.0
2 parents 088d258 + 8385f45 commit 9e1b12f

File tree

6 files changed

+116
-2
lines changed

6 files changed

+116
-2
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"php": "^7.0",
99
"ext-json": "*",
1010
"composer/composer": "@stable",
11+
"composer/semver": "^1.5",
1112
"symfony/config": "^3.3||^4.4",
1213
"symfony/console": "^2.8||^4.0",
1314
"symfony/dependency-injection": "^3.3||^4.3",

config/services.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
<service id="Magento\CloudPatches\Command\Patch\ManagerException" autowire="false"/>
1414
<service id="Magento\CloudPatches\Patch\ApplierException" autowire="false"/>
1515
<service id="Magento\CloudPatches\Filesystem\FileNotFoundException" autowire="false"/>
16+
<service id="Magento\CloudPatches\Shell\PackageNotFoundException" autowire="false"/>
1617
</services>
1718
</container>

patches.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@
238238
},
239239
"Fix for multi-site configuration issue": {
240240
"2.2.4": "MAGETWO-92926__fix_for_multi-site_configuration_issue__2.2.4.patch"
241+
},
242+
"Fix PayPal issue with region": {
243+
"2.3.4": "MC-31387__fix_paypal_issue_with_region__2.3.4.patch"
241244
}
242245
},
243246
"monolog/monolog": {
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
diff -Nuar a/vendor/magento/module-paypal/Model/Api/Nvp.php b/vendor/magento/module-paypal/Model/Api/Nvp.php
2+
--- a/vendor/magento/module-paypal/Model/Api/Nvp.php
3+
+++ b/vendor/magento/module-paypal/Model/Api/Nvp.php
4+
@@ -1512,17 +1512,17 @@
5+
}
6+
// attempt to fetch region_id from directory
7+
if ($address->getCountryId() && $address->getRegion()) {
8+
- $regions = $this->_countryFactory->create()->loadByCode(
9+
- $address->getCountryId()
10+
- )->getRegionCollection()->addRegionCodeOrNameFilter(
11+
- $address->getRegion()
12+
- )->setPageSize(
13+
- 1
14+
- );
15+
+ $regions = $this->_countryFactory->create()
16+
+ ->getRegionCollection()
17+
+ ->addCountryFilter($address->getCountryId())
18+
+ ->addRegionCodeOrNameFilter($address->getRegion())
19+
+ ->setPageSize(1);
20+
$regionItems = $regions->getItems();
21+
- $region = array_shift($regionItems);
22+
- $address->setRegionId($region->getId());
23+
- $address->setExportedKeys(array_merge($address->getExportedKeys(), ['region_id']));
24+
+ if (count($regionItems)) {
25+
+ $region = array_shift($regionItems);
26+
+ $address->setRegionId($region->getId());
27+
+ $address->setExportedKeys(array_merge($address->getExportedKeys(), ['region_id']));
28+
+ }
29+
}
30+
}
31+
32+
@@ -1624,7 +1624,7 @@
33+
case 'year':
34+
return 'Year';
35+
default:
36+
- break;
37+
+ return '';
38+
}
39+
}
40+
41+
@@ -1653,7 +1653,7 @@
42+
case 'active':
43+
return 'Active';
44+
default:
45+
- break;
46+
+ return '';
47+
}
48+
}
49+
50+
@@ -1694,7 +1694,7 @@
51+
case 'Voided':
52+
return \Magento\Paypal\Model\Info::PAYMENTSTATUS_VOIDED;
53+
default:
54+
- break;
55+
+ return null;
56+
}
57+
}
58+
59+
@@ -1712,7 +1712,7 @@
60+
case \Magento\Paypal\Model\Pro::PAYMENT_REVIEW_DENY:
61+
return 'Deny';
62+
default:
63+
- break;
64+
+ return null;
65+
}
66+
}
67+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CloudPatches\Shell;
9+
10+
use Magento\CloudPatches\App\GenericException;
11+
12+
/**
13+
* Exception if a Composer package could not be found for some reason (e.g., symfony/process).
14+
*/
15+
class PackageNotFoundException extends GenericException
16+
{
17+
}

src/Shell/ProcessFactory.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
namespace Magento\CloudPatches\Shell;
99

10+
use Composer\Composer;
11+
use Composer\Repository\RepositoryInterface;
12+
use Composer\Semver\Comparator;
1013
use Magento\CloudPatches\Filesystem\DirectoryList;
1114
use Symfony\Component\Process\Process;
1215

@@ -17,17 +20,25 @@
1720
*/
1821
class ProcessFactory
1922
{
23+
const ARRAY_PARAM_MIN_VERSION = '3.3.0';
24+
2025
/**
2126
* @var DirectoryList
2227
*/
2328
private $directoryList;
2429

30+
/**
31+
* @var RepositoryInterface
32+
*/
33+
private $repository;
34+
2535
/**
2636
* @param DirectoryList $directoryList
2737
*/
28-
public function __construct(DirectoryList $directoryList)
38+
public function __construct(DirectoryList $directoryList, Composer $composer)
2939
{
3040
$this->directoryList = $directoryList;
41+
$this->repository = $composer->getLocker()->getLockedRepository();
3142
}
3243

3344
/**
@@ -37,8 +48,22 @@ public function __construct(DirectoryList $directoryList)
3748
public function create(array $cmd): Process
3849
{
3950
return new Process(
40-
implode(' ', $cmd),
51+
$this->processSupportsArrayParam() ? $cmd : implode(' ', $cmd),
4152
$this->directoryList->getMagentoRoot()
4253
);
4354
}
55+
56+
/**
57+
* Test if symfony/process is current enough to support an array for its first parameter.
58+
*/
59+
private function processSupportsArrayParam(): bool
60+
{
61+
$package = $this->repository->findPackage('symfony/process', '*');
62+
63+
if ($package === null) {
64+
throw new PackageNotFoundException('Could not find symfony/process package.');
65+
}
66+
67+
return Comparator::greaterThanOrEqualTo($package->getVersion(), self::ARRAY_PARAM_MIN_VERSION);
68+
}
4469
}

0 commit comments

Comments
 (0)