Skip to content

Commit

Permalink
🔃 [EngCom] Public Pull Requests - 2.2-develop
Browse files Browse the repository at this point in the history
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
  • Loading branch information
magento-engcom-team authored Apr 20, 2019
2 parents 40b8c25 + cfbd77e commit c52ee4a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,15 @@ public function execute(\Magento\Framework\Event\Observer $observer)
if ($purchasedLink->getId()) {
return $this;
}
$storeId = $orderItem->getOrder()->getStoreId();
$orderStatusToEnableItem = $this->_scopeConfig->getValue(
\Magento\Downloadable\Model\Link\Purchased\Item::XML_PATH_ORDER_ITEM_STATUS,
ScopeInterface::SCOPE_STORE,
$storeId
);
if (!$product) {
$product = $this->_createProductModel()->setStoreId(
$orderItem->getOrder()->getStoreId()
$storeId
)->load(
$orderItem->getProductId()
);
Expand Down Expand Up @@ -150,6 +156,8 @@ public function execute(\Magento\Framework\Event\Observer $observer)
)->setNumberOfDownloadsBought(
$numberOfDownloads
)->setStatus(
\Magento\Sales\Model\Order\Item::STATUS_PENDING == $orderStatusToEnableItem ?
\Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_AVAILABLE :
\Magento\Downloadable\Model\Link\Purchased\Item::LINK_STATUS_PENDING
)->setCreatedAt(
$orderItem->getCreatedAt()
Expand Down
17 changes: 14 additions & 3 deletions lib/internal/Magento/Framework/App/DocRootLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Framework\App;

use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\ReadFactory;

/**
Expand All @@ -20,18 +22,26 @@ class DocRootLocator
private $request;

/**
* @deprecated
* @var ReadFactory
*/
private $readFactory;

/**
* @var Filesystem
*/
private $filesystem;

/**
* @param RequestInterface $request
* @param ReadFactory $readFactory
* @param Filesystem|null $filesystem
*/
public function __construct(RequestInterface $request, ReadFactory $readFactory)
public function __construct(RequestInterface $request, ReadFactory $readFactory, Filesystem $filesystem = null)
{
$this->request = $request;
$this->readFactory = $readFactory;
$this->filesystem = $filesystem ?: ObjectManager::getInstance()->get(Filesystem::class);
}

/**
Expand All @@ -42,7 +52,8 @@ public function __construct(RequestInterface $request, ReadFactory $readFactory)
public function isPub()
{
$rootBasePath = $this->request->getServer('DOCUMENT_ROOT');
$readDirectory = $this->readFactory->create(DirectoryList::ROOT);
return (substr($rootBasePath, -strlen('/pub')) === '/pub') && !$readDirectory->isExist($rootBasePath . 'setup');
$readDirectory = $this->filesystem->getDirectoryRead(DirectoryList::ROOT);

return (substr($rootBasePath, -\strlen('/pub')) === '/pub') && ! $readDirectory->isExist('setup');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

use Magento\Framework\App\DocRootLocator;

/**
* Test for Magento\Framework\App\DocRootLocator class.
*/
class DocRootLocatorTest extends \PHPUnit\Framework\TestCase
{
/**
Expand All @@ -21,11 +24,15 @@ public function testIsPub($path, $isExist, $result)
{
$request = $this->createMock(\Magento\Framework\App\Request\Http::class);
$request->expects($this->once())->method('getServer')->willReturn($path);

$readFactory = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class);

$reader = $this->createMock(\Magento\Framework\Filesystem\Directory\Read::class);
$filesystem = $this->createMock(\Magento\Framework\Filesystem::class);
$filesystem->expects($this->once())->method('getDirectoryRead')->willReturn($reader);
$reader->expects($this->any())->method('isExist')->willReturn($isExist);
$readFactory = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadFactory::class);
$readFactory->expects($this->once())->method('create')->willReturn($reader);
$model = new DocRootLocator($request, $readFactory);

$model = new DocRootLocator($request, $readFactory, $filesystem);
$this->assertSame($result, $model->isPub());
}

Expand Down

0 comments on commit c52ee4a

Please sign in to comment.