Skip to content

Commit

Permalink
[EngCom] Public Pull Requests - 2.3-develop
Browse files Browse the repository at this point in the history
 - merged latest code from mainline branch
  • Loading branch information
magento-engcom-team authored Mar 30, 2019
2 parents d75589f + 19c196e commit 4bbc07d
Show file tree
Hide file tree
Showing 99 changed files with 1,933 additions and 2,834 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function calculate(FieldNode $fieldNode) : int
$depth = count($selections) ? 1 : 0;
$childrenDepth = [0];
foreach ($selections as $node) {
if ($node->kind === 'InlineFragment') {
if ($node->kind === 'InlineFragment' || null !== $node->alias) {
continue;
}

Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/CatalogGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ input ProductFilterInput @doc(description: "ProductFilterInput defines the filte
description: FilterTypeInput @doc(description: "Detailed information about the product. The value can include simple HTML tags.")
short_description: FilterTypeInput @doc(description: "A short description of the product. Its use depends on the theme.")
price: FilterTypeInput @doc(description: "The price of an item")
special_price: FilterTypeInput @doc(description: "The discounted price of the product")
special_price: FilterTypeInput @doc(description: "The discounted price of the product. Do not include the currency code.")
special_from_date: FilterTypeInput @doc(description: "The beginning date that a product has a special price")
special_to_date: FilterTypeInput @doc(description: "The end date that a product has a special price")
weight: FilterTypeInput @doc(description: "The weight of the item, in units defined by the store")
Expand All @@ -477,7 +477,6 @@ input ProductFilterInput @doc(description: "ProductFilterInput defines the filte
custom_layout_update: FilterTypeInput @doc(description: "XML code that is applied as a layout update to the product page")
min_price: FilterTypeInput @doc(description:"The numeric minimal price of the product. Do not include the currency code.")
max_price: FilterTypeInput @doc(description:"The numeric maximal price of the product. Do not include the currency code.")
special_price: FilterTypeInput @doc(description:"The numeric special price of the product. Do not include the currency code.")
category_id: FilterTypeInput @doc(description: "Category ID the product belongs to")
options_container: FilterTypeInput @doc(description: "If the product has multiple options, determines where they appear on the product page")
required_options: FilterTypeInput @doc(description: "Indicates whether the product has required options")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Config\Observer\Config\Backend\Admin;

use Magento\Framework\Event\ObserverInterface;

/**
* Class AfterCustomUrlChangedObserver redirects to new custom admin URL.
*
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
*/
class AfterCustomUrlChangedObserver implements ObserverInterface
{
/**
Expand Down Expand Up @@ -56,7 +63,6 @@ public function __construct(
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute(\Magento\Framework\Event\Observer $observer)
Expand All @@ -68,6 +74,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
$this->_authSession->destroy();
$adminUrl = $this->_backendData->getHomePageUrl();
$this->_response->setRedirect($adminUrl)->sendResponse();
// phpcs:ignore Magento2.Security.LanguageConstruct.ExitUsage
exit(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Customer\Controller\Adminhtml\Index;

use Magento\Customer\Api\AccountManagementInterface;
Expand All @@ -17,7 +19,10 @@
use Magento\Framework\DataObjectFactory;

/**
* Class Viewfile serves to show file or image by file/image name provided in request parameters.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.AllPurposeAction)
*/
class Viewfile extends \Magento\Customer\Controller\Adminhtml\Index
{
Expand Down Expand Up @@ -127,8 +132,6 @@ public function __construct(
*
* @return \Magento\Framework\Controller\ResultInterface|void
* @throws NotFoundException
*
* @SuppressWarnings(PHPMD.ExitExpression)
*/
public function execute()
{
Expand All @@ -146,6 +149,7 @@ public function execute()
}

if ($plain) {
// phpcs:ignore Magento2.Functions.DiscouragedFunction
$extension = pathinfo($path, PATHINFO_EXTENSION);
switch (strtolower($extension)) {
case 'gif':
Expand Down Expand Up @@ -175,6 +179,7 @@ public function execute()
$resultRaw->setContents($directory->readFile($fileName));
return $resultRaw;
} else {
// phpcs:ignore Magento2.Functions.DiscouragedFunction
$name = pathinfo($path, PATHINFO_BASENAME);
$this->_fileFactory->create(
$name,
Expand Down
32 changes: 28 additions & 4 deletions app/code/Magento/Deploy/Process/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Deploy\Process;

use Magento\Deploy\Package\Package;
Expand Down Expand Up @@ -125,6 +127,8 @@ public function __construct(
}

/**
* Adds deployment package.
*
* @param Package $package
* @param Package[] $dependencies
* @return bool true on success
Expand All @@ -140,6 +144,8 @@ public function add(Package $package, array $dependencies = [])
}

/**
* Returns packages array.
*
* @return Package[]
*/
public function getPackages()
Expand All @@ -162,6 +168,7 @@ public function process()
$this->assertAndExecute($name, $packages, $packageJob);
}
$this->logger->info('.');
// phpcs:ignore Magento2.Functions.DiscouragedFunction
sleep(3);
foreach ($this->inProgress as $name => $package) {
if ($this->isDeployed($package)) {
Expand Down Expand Up @@ -209,6 +216,8 @@ private function assertAndExecute($name, array & $packages, array $packageJob)
}

/**
* Executes deployment package.
*
* @param Package $package
* @param string $name
* @param array $packages
Expand Down Expand Up @@ -244,6 +253,7 @@ private function awaitForAllProcesses()
}
}
$this->logger->info('.');
// phpcs:ignore Magento2.Functions.DiscouragedFunction
sleep(5);
}
if ($this->isCanBeParalleled()) {
Expand All @@ -253,6 +263,8 @@ private function awaitForAllProcesses()
}

/**
* Checks if can be parallel.
*
* @return bool
*/
private function isCanBeParalleled()
Expand All @@ -261,9 +273,11 @@ private function isCanBeParalleled()
}

/**
* Executes the process.
*
* @param Package $package
* @return bool true on success for main process and exit for child process
* @SuppressWarnings(PHPMD.ExitExpression)
* @throws \RuntimeException
*/
private function execute(Package $package)
{
Expand Down Expand Up @@ -291,6 +305,7 @@ function () use ($package) {
);

if ($this->isCanBeParalleled()) {
// phpcs:ignore Magento2.Functions.DiscouragedFunction
$pid = pcntl_fork();
if ($pid === -1) {
throw new \RuntimeException('Unable to fork a new process');
Expand All @@ -305,6 +320,7 @@ function () use ($package) {
// process child process
$this->inProgress = [];
$this->deployPackageService->deploy($package, $this->options, true);
// phpcs:ignore Magento2.Security.LanguageConstruct.ExitUsage
exit(0);
} else {
$this->deployPackageService->deploy($package, $this->options);
Expand All @@ -313,18 +329,22 @@ function () use ($package) {
}

/**
* Checks if package is deployed.
*
* @param Package $package
* @return bool
*/
private function isDeployed(Package $package)
{
if ($this->isCanBeParalleled()) {
if ($package->getState() === null) {
// phpcs:ignore Magento2.Functions.DiscouragedFunction
$pid = pcntl_waitpid($this->getPid($package), $status, WNOHANG);
if ($pid === $this->getPid($package)) {
$package->setState(Package::STATE_COMPLETED);

unset($this->inProgress[$package->getPath()]);
// phpcs:ignore Magento2.Functions.DiscouragedFunction
return pcntl_wexitstatus($status) === 0;
}
return false;
Expand All @@ -334,17 +354,19 @@ private function isDeployed(Package $package)
}

/**
* Returns process ID or null if not found.
*
* @param Package $package
* @return int|null
*/
private function getPid(Package $package)
{
return isset($this->processIds[$package->getPath()])
? $this->processIds[$package->getPath()]
: null;
return isset($this->processIds[$package->getPath()]) ?? null;
}

/**
* Checks timeout.
*
* @return bool
*/
private function checkTimeout()
Expand All @@ -357,11 +379,13 @@ private function checkTimeout()
*
* Protect against zombie process
*
* @throws \RuntimeException
* @return void
*/
public function __destruct()
{
foreach ($this->inProgress as $package) {
// phpcs:ignore Magento2.Functions.DiscouragedFunction
if (pcntl_waitpid($this->getPid($package), $status) === -1) {
throw new \RuntimeException(
'Error while waiting for package deployed: ' . $this->getPid($package) . '; Status: ' . $status
Expand Down
10 changes: 8 additions & 2 deletions app/code/Magento/Downloadable/Controller/Download/Link.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Downloadable\Controller\Download;

use Magento\Downloadable\Helper\Download as DownloadHelper;
use Magento\Downloadable\Model\Link\Purchased\Item as PurchasedLink;
use Magento\Framework\App\ResponseInterface;

/**
* Class Link executes download link action.
*
* @SuppressWarnings(PHPMD.AllPurposeAction)
*/
class Link extends \Magento\Downloadable\Controller\Download
{
/**
Expand All @@ -29,7 +35,6 @@ protected function _getCustomerSession()
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.ExitExpression)
*/
public function execute()
{
Expand Down Expand Up @@ -117,6 +122,7 @@ public function execute()
$linkPurchasedItem->setStatus(PurchasedLink::LINK_STATUS_EXPIRED);
}
$linkPurchasedItem->save();
// phpcs:ignore Magento2.Security.LanguageConstruct.ExitUsage
exit(0);
} catch (\Exception $e) {
$this->messageManager->addError(__('Something went wrong while getting the requested content.'));
Expand Down
10 changes: 8 additions & 2 deletions app/code/Magento/Downloadable/Controller/Download/LinkSample.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Downloadable\Controller\Download;

use Magento\Downloadable\Helper\Download as DownloadHelper;
use Magento\Framework\App\ResponseInterface;

/**
* Class LinkSample executes download sample link action.
*
* @SuppressWarnings(PHPMD.AllPurposeAction)
*/
class LinkSample extends \Magento\Downloadable\Controller\Download
{
/**
* Download link's sample action
*
* @return ResponseInterface
* @SuppressWarnings(PHPMD.ExitExpression)
*/
public function execute()
{
Expand All @@ -39,6 +44,7 @@ public function execute()
}
try {
$this->_processDownload($resource, $resourceType);
// phpcs:ignore Magento2.Security.LanguageConstruct.ExitUsage
exit(0);
} catch (\Exception $e) {
$this->messageManager->addError(
Expand Down
10 changes: 8 additions & 2 deletions app/code/Magento/Downloadable/Controller/Download/Sample.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Downloadable\Controller\Download;

use Magento\Downloadable\Helper\Download as DownloadHelper;
use Magento\Framework\App\ResponseInterface;

/**
* Class Sample executes download sample action.
*
* @SuppressWarnings(PHPMD.AllPurposeAction)
*/
class Sample extends \Magento\Downloadable\Controller\Download
{
/**
* Download sample action
*
* @return ResponseInterface
* @SuppressWarnings(PHPMD.ExitExpression)
*/
public function execute()
{
Expand All @@ -36,6 +41,7 @@ public function execute()
}
try {
$this->_processDownload($resource, $resourceType);
// phpcs:ignore Magento2.Security.LanguageConstruct.ExitUsage
exit(0);
} catch (\Exception $e) {
$this->messageManager->addError(
Expand Down
Loading

0 comments on commit 4bbc07d

Please sign in to comment.