Skip to content

Log undeclared plugin only if it is not disabled #40081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: 2.4-develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
* Copyright 2020 Adobe
* All Rights Reserved.
*/
declare(strict_types=1);

namespace Magento\Framework\Interception;

use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\State;
use Magento\Framework\Config\ReaderInterface;
use Magento\Framework\Config\ScopeInterface;
use Magento\Framework\Interception\ObjectManager\ConfigInterface;
Expand Down Expand Up @@ -104,6 +106,11 @@ class PluginListGenerator implements ConfigWriterInterface, ConfigLoaderInterfac
*/
private $scopePriorityScheme;

/**
* @var State
*/
private State $appState;

/**
* @var array
*/
Expand All @@ -119,6 +126,7 @@ class PluginListGenerator implements ConfigWriterInterface, ConfigLoaderInterfac
* @param LoggerInterface $logger
* @param DirectoryList $directoryList
* @param array $scopePriorityScheme
* @param State|null $appState
*/
public function __construct(
ReaderInterface $reader,
Expand All @@ -129,7 +137,8 @@ public function __construct(
ClassDefinitions $classDefinitions,
LoggerInterface $logger,
DirectoryList $directoryList,
array $scopePriorityScheme = ['global']
array $scopePriorityScheme = ['global'],
?State $appState = null
) {
$this->reader = $reader;
$this->scopeConfig = $scopeConfig;
Expand All @@ -140,6 +149,7 @@ public function __construct(
$this->logger = $logger;
$this->directoryList = $directoryList;
$this->scopePriorityScheme = $scopePriorityScheme;
$this->appState = $appState ?? ObjectManager::getInstance()->get(State::class);
}

/**
Expand Down Expand Up @@ -366,9 +376,12 @@ public function trimInstanceStartingBackslash(&$plugins)
public function filterPlugins(array &$plugins)
{
foreach ($plugins as $name => $plugin) {
if (empty($plugin['instance'])) {
if (!isset($plugin['instance'])) {
unset($plugins[$name]);
$this->logger->info("Reference to undeclared plugin with name '{$name}'.");
// Log the undeclared plugin when it is not disabled or when the app is in Developer mode.
if ($this->appState->getMode() === State::MODE_DEVELOPER || !($plugin['disabled'] ?? false)) {
$this->logger->debug("Reference to undeclared plugin with name '{$name}'.");
}
}
}
}
Expand Down