Skip to content

Commit

Permalink
Merge pull request #8163 from magento-gl/comm_78764_31355
Browse files Browse the repository at this point in the history
[Bluetooth] Community Pull Requests delivery - 2.4-develop
  • Loading branch information
sidolov authored Feb 23, 2023
2 parents 0727043 + e8c2b3a commit 647b34e
Show file tree
Hide file tree
Showing 13 changed files with 187 additions and 85 deletions.
10 changes: 7 additions & 3 deletions app/code/Magento/Bundle/Model/Plugin/PriceBackend.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<?php

/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Bundle\Model\Plugin;

/**
* Class PriceBackend
*
* Make price validation optional for bundle dynamic
* Make price validation optional for bundle dynamic
*/
class PriceBackend
{
/**
* Around validate
*
* @param \Magento\Catalog\Model\Product\Attribute\Backend\Price $subject
* @param \Closure $proceed
* @param \Magento\Catalog\Model\Product|\Magento\Framework\DataObject $object
Expand All @@ -30,6 +33,7 @@ public function aroundValidate(
) {
return true;
}

return $proceed($object);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\ConfigurableProduct\Model\Plugin;

use Magento\Catalog\Api\Data\ProductInterface;
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;

/**
* Class PriceBackend
*
* Make price validation optional for configurable product
* Make price validation optional for configurable product
*/
class PriceBackend
{
/**
* Around validate
*
* @param \Magento\Catalog\Model\Product\Attribute\Backend\Price $subject
* @param \Closure $proceed
* @param \Magento\Catalog\Model\Product|\Magento\Framework\DataObject $object
Expand All @@ -26,12 +29,10 @@ public function aroundValidate(
\Closure $proceed,
$object
) {
if ($object instanceof \Magento\Catalog\Model\Product
&& $object->getTypeId() == Configurable::TYPE_CODE
) {
if ($object instanceof ProductInterface && $object->getTypeId() === Configurable::TYPE_CODE) {
return true;
} else {
return $proceed($object);
}

return $proceed($object);
}
}
38 changes: 37 additions & 1 deletion app/code/Magento/Cron/Observer/ProcessCronQueueObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
namespace Magento\Cron\Observer;

use Laminas\Http\PhpEnvironment\Request as Environment;
use Exception;
use Magento\Cron\Model\DeadlockRetrierInterface;
use Magento\Cron\Model\ResourceModel\Schedule\Collection as ScheduleCollection;
Expand Down Expand Up @@ -133,6 +134,16 @@ class ProcessCronQueueObserver implements ObserverInterface
*/
protected $dateTime;

/**
* @var Environment
*/
private Environment $environment;

/**
* @var string
*/
private string $originalProcessTitle;

/**
* @var \Symfony\Component\Process\PhpExecutableFinder
*/
Expand Down Expand Up @@ -189,6 +200,7 @@ class ProcessCronQueueObserver implements ObserverInterface
* @param \Magento\Framework\Lock\LockManagerInterface $lockManager
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param DeadlockRetrierInterface $retrier
* @param Environment $environment
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -206,7 +218,8 @@ public function __construct(
StatFactory $statFactory,
\Magento\Framework\Lock\LockManagerInterface $lockManager,
\Magento\Framework\Event\ManagerInterface $eventManager,
DeadlockRetrierInterface $retrier
DeadlockRetrierInterface $retrier,
Environment $environment
) {
$this->_objectManager = $objectManager;
$this->_scheduleFactory = $scheduleFactory;
Expand All @@ -216,6 +229,7 @@ public function __construct(
$this->_request = $request;
$this->_shell = $shell;
$this->dateTime = $dateTime;
$this->environment = $environment;
$this->phpExecutableFinder = $phpExecutableFinderFactory->create();
$this->logger = $logger;
$this->state = $state;
Expand Down Expand Up @@ -354,6 +368,8 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,
);
}

$this->setProcessTitle($jobCode, $groupId);

$schedule->setExecutedAt(date('Y-m-d H:i:s', $this->dateTime->gmtTimestamp()));
$this->retrier->execute(
function () use ($schedule) {
Expand Down Expand Up @@ -944,4 +960,24 @@ function () use ($scheduleResource, $where) {
$scheduleResource->getConnection()
);
}

/**
* Set the process title to include the job code and group
*
* @param string $jobCode
* @param string $groupId
*/
private function setProcessTitle(string $jobCode, string $groupId): void
{
if (!isset($this->originalProcessTitle)) {
$this->originalProcessTitle = PHP_BINARY . ' ' . implode(' ', $this->environment->getServer('argv'));
}

if (strpos($this->originalProcessTitle, " --group=$groupId ") !== false) {
// Group is already shown, so no need to include here in duplicate
cli_set_process_title($this->originalProcessTitle . " # job: $jobCode");
} else {
cli_set_process_title($this->originalProcessTitle . " # group: $groupId, job: $jobCode");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Magento\Cron\Test\Unit\Observer;

use Exception;
use Laminas\Http\PhpEnvironment\Request as Environment;
use Magento\Cron\Model\Config;
use Magento\Cron\Model\DeadlockRetrierInterface;
use Magento\Cron\Model\ResourceModel\Schedule as ScheduleResourceModel;
Expand All @@ -20,8 +21,8 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Console\Request as ConsoleRequest;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\State;
use Magento\Framework\App\State as AppState;
use Magento\Framework\App\State;
use Magento\Framework\DataObject;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Event\ManagerInterface;
Expand Down Expand Up @@ -219,6 +220,14 @@ protected function setUp(): void

$this->retrierMock = $this->getMockForAbstractClass(DeadlockRetrierInterface::class);

$environmentMock = $this->getMockBuilder(Environment::class)
->disableOriginalConstructor()
->getMock();
$environmentMock->expects($this->any())
->method('getServer')
->with('argv')
->willReturn([]);

$this->cronQueueObserver = new ProcessCronQueueObserver(
$this->objectManagerMock,
$this->scheduleFactoryMock,
Expand All @@ -234,7 +243,8 @@ protected function setUp(): void
$this->statFactory,
$this->lockManagerMock,
$this->eventManager,
$this->retrierMock
$this->retrierMock,
$environmentMock
);
}

Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Store/Model/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Magento\Framework\Url\ScopeInterface as UrlScopeInterface;
use Magento\Framework\UrlInterface;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\StoreManager;

/**
* Store model
Expand Down Expand Up @@ -760,6 +761,7 @@ protected function _updatePathUseStoreView($url)
public function isUseStoreInUrl()
{
return !($this->hasDisableStoreInUrl() && $this->getDisableStoreInUrl())
&& !$this->getConfig(StoreManager::XML_PATH_SINGLE_STORE_MODE_ENABLED)
&& $this->getConfig(self::XML_PATH_STORE_IN_URL);
}

Expand Down
10 changes: 6 additions & 4 deletions app/code/Magento/Store/Url/Plugin/SecurityInfo.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\Store\Url\Plugin;

use \Magento\Store\Model\Store;
use \Magento\Store\Model\ScopeInterface as StoreScopeInterface;
use Magento\Store\Model\ScopeInterface as StoreScopeInterface;
use Magento\Store\Model\Store;

/**
* Plugin for \Magento\Framework\Url\SecurityInfo
Expand Down Expand Up @@ -39,8 +41,8 @@ public function aroundIsSecure(\Magento\Framework\Url\SecurityInfo $subject, \Cl
{
if ($this->scopeConfig->getValue(Store::XML_PATH_SECURE_IN_FRONTEND, StoreScopeInterface::SCOPE_STORE)) {
return $proceed($url);
} else {
return false;
}

return false;
}
}
Loading

0 comments on commit 647b34e

Please sign in to comment.