Skip to content

Commit c52ee4a

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #22072: [Backport] Bug fix for #21753 (2.2-develop) (by @crankycyclops) - #22369: [Backport 2.2] Use correct base path to check if setup folder exists (by @JeroenVanLeusden) Fixed GitHub Issues: - #21753: Order Item Status to Enable Downloads is set to "Pending," but no download links are presented in "My Downloads" when logged in (fix provided) (reported by @crankycyclops) has been fixed in #22072 by @crankycyclops in 2.2-develop branch Related commits: 1. aaae03f 2. e644ea7 3. 19cc768 4. 1c5c0c8 - #7623: Web Setup Wizard not visible in backend (V.2.1.2) ONGOING (reported by @dharake) has been fixed in #22369 by @JeroenVanLeusden in 2.2-develop branch Related commits: 1. 10de6de 2. 40b5d2e - #11892: Web Setup Wizard not visible in backend magento 2.1.9 (reported by @amithlalalj) has been fixed in #22369 by @JeroenVanLeusden in 2.2-develop branch Related commits: 1. 10de6de 2. 40b5d2e
2 parents 40b8c25 + cfbd77e commit c52ee4a

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

app/code/Magento/Downloadable/Observer/SaveDownloadableOrderItemObserver.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,15 @@ public function execute(\Magento\Framework\Event\Observer $observer)
9292
if ($purchasedLink->getId()) {
9393
return $this;
9494
}
95+
$storeId = $orderItem->getOrder()->getStoreId();
96+
$orderStatusToEnableItem = $this->_scopeConfig->getValue(
97+
\Magento\Downloadable\Model\Link\Purchased\Item::XML_PATH_ORDER_ITEM_STATUS,
98+
ScopeInterface::SCOPE_STORE,
99+
$storeId
100+
);
95101
if (!$product) {
96102
$product = $this->_createProductModel()->setStoreId(
97-
$orderItem->getOrder()->getStoreId()
103+
$storeId
98104
)->load(
99105
$orderItem->getProductId()
100106
);
@@ -150,6 +156,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
150156
)->setNumberOfDownloadsBought(
151157
$numberOfDownloads
152158
)->setStatus(
159+
\Magento\Sales\Model\Order\Item::STATUS_PENDING == $orderStatusToEnableItem ?
160+
\Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_AVAILABLE :
153161
\Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING
154162
)->setCreatedAt(
155163
$orderItem->getCreatedAt()

lib/internal/Magento/Framework/App/DocRootLocator.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Framework\App;
89

910
use Magento\Framework\App\Filesystem\DirectoryList;
11+
use Magento\Framework\Filesystem;
1012
use Magento\Framework\Filesystem\Directory\ReadFactory;
1113

1214
/**
@@ -20,18 +22,26 @@ class DocRootLocator
2022
private $request;
2123

2224
/**
25+
* @deprecated
2326
* @var ReadFactory
2427
*/
2528
private $readFactory;
2629

30+
/**
31+
* @var Filesystem
32+
*/
33+
private $filesystem;
34+
2735
/**
2836
* @param RequestInterface $request
2937
* @param ReadFactory $readFactory
38+
* @param Filesystem|null $filesystem
3039
*/
31-
public function __construct(RequestInterface $request, ReadFactory $readFactory)
40+
public function __construct(RequestInterface $request, ReadFactory $readFactory, Filesystem $filesystem = null)
3241
{
3342
$this->request = $request;
3443
$this->readFactory = $readFactory;
44+
$this->filesystem = $filesystem ?: ObjectManager::getInstance()->get(Filesystem::class);
3545
}
3646

3747
/**
@@ -42,7 +52,8 @@ public function __construct(RequestInterface $request, ReadFactory $readFactory)
4252
public function isPub()
4353
{
4454
$rootBasePath = $this->request->getServer('DOCUMENT_ROOT');
45-
$readDirectory = $this->readFactory->create(DirectoryList::ROOT);
46-
return (substr($rootBasePath, -strlen('/pub')) === '/pub') && !$readDirectory->isExist($rootBasePath . 'setup');
55+
$readDirectory = $this->filesystem->getDirectoryRead(DirectoryList::ROOT);
56+
57+
return (substr($rootBasePath, -\strlen('/pub')) === '/pub') && ! $readDirectory->isExist('setup');
4758
}
4859
}

lib/internal/Magento/Framework/App/Test/Unit/DocRootLocatorTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
use Magento\Framework\App\DocRootLocator;
1010

11+
/**
12+
* Test for Magento\Framework\App\DocRootLocator class.
13+
*/
1114
class DocRootLocatorTest extends \PHPUnit\Framework\TestCase
1215
{
1316
/**
@@ -21,11 +24,15 @@ public function testIsPub($path, $isExist, $result)
2124
{
2225
$request = $this->createMock(\Magento\Framework\App\Request\Http::class);
2326
$request->expects($this->once())->method('getServer')->willReturn($path);
27+
28+
$readFactory = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class);
29+
2430
$reader = $this->createMock(\Magento\Framework\Filesystem\Directory\Read::class);
31+
$filesystem = $this->createMock(\Magento\Framework\Filesystem::class);
32+
$filesystem->expects($this->once())->method('getDirectoryRead')->willReturn($reader);
2533
$reader->expects($this->any())->method('isExist')->willReturn($isExist);
26-
$readFactory = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class);
27-
$readFactory->expects($this->once())->method('create')->willReturn($reader);
28-
$model = new DocRootLocator($request, $readFactory);
34+
35+
$model = new DocRootLocator($request, $readFactory, $filesystem);
2936
$this->assertSame($result, $model->isPub());
3037
}
3138

0 commit comments

Comments
 (0)