fix not existing component issue in admin panels login controller

Cette révision appartient à :
Daniel Seifert 2022-08-15 15:44:51 +02:00
Parent 4b47e5ddb6
révision ff606efef3
Signé par: DanielS
ID de la clé GPG: 8A7C4C6ED1915C6F
2 fichiers modifiés avec 41 ajouts et 30 suppressions

Voir le fichier

@ -36,7 +36,6 @@ class DebugBarExceptionHandler
*/ */
public function handleUncaughtException(Throwable $exception) public function handleUncaughtException(Throwable $exception)
{ {
//dumpvar(__METHOD__.__LINE__);
try { try {
$debugMode = (bool) \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Core\ConfigFile::class)->getVar('iDebug'); $debugMode = (bool) \OxidEsales\Eshop\Core\Registry::get(\OxidEsales\Eshop\Core\ConfigFile::class)->getVar('iDebug');
$defaultExceptionHandler = new ExceptionHandler($debugMode); $defaultExceptionHandler = new ExceptionHandler($debugMode);
@ -56,11 +55,9 @@ class DebugBarExceptionHandler
} }
global $debugBarSet; global $debugBarSet;
if ($debugBarSet !== 1) { if ($debugBarSet !== 1 && false === isAdmin()) {
/** @var FrontendController $activeView */ /** @var DebugBarComponent $debugBarComponent */
$activeView = Registry::getConfig()->getTopActiveView(); $debugBarComponent = oxNew( DebugBarComponent::class );
/** @var DebugBarComponent|null $debugBarComponent */
$debugBarComponent = $activeView->getComponent(DebugBarComponent::class) ?: oxNew(DebugBarComponent::class);
/** @var ExceptionsCollector $excCollector */ /** @var ExceptionsCollector $excCollector */
$excCollector = $debugBarComponent->getDebugBar()->getCollector('exceptions'); $excCollector = $debugBarComponent->getDebugBar()->getCollector('exceptions');

Voir le fichier

@ -42,19 +42,21 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
*/ */
public function d3DebugBarSetErrorHandler() public function d3DebugBarSetErrorHandler()
{ {
set_error_handler(function ($severity, $message, $file, $line) { if ($this->d3CanActivateDebugBar()) {
if (!(error_reporting() & $severity)) { set_error_handler( function( $severity, $message, $file, $line ) {
// This error code is not included in error_reporting. if ( ! ( error_reporting() & $severity ) ) {
return; // This error code is not included in error_reporting.
} return;
}
$smartyTemplate = $this->getSmartyTemplateLocationFromError($message); $smartyTemplate = $this->getSmartyTemplateLocationFromError( $message );
if (is_array($smartyTemplate)) { if ( is_array( $smartyTemplate ) ) {
[$file, $line] = $smartyTemplate; [ $file, $line ] = $smartyTemplate;
} }
throw new ErrorException($message, 0, $severity, $file, $line); throw new ErrorException( $message, 0, $severity, $file, $line );
}); } );
}
} }
/** /**
@ -62,10 +64,12 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
*/ */
protected function d3DebugBarSetExceptionHandler(): void protected function d3DebugBarSetExceptionHandler(): void
{ {
set_exception_handler([ if ($this->d3CanActivateDebugBar()) {
new DebugBarExceptionHandler(), set_exception_handler( [
'handleUncaughtException' new DebugBarExceptionHandler(),
]); 'handleUncaughtException'
] );
}
} }
/** /**
@ -89,20 +93,30 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
*/ */
protected function d3AddDebugBarComponent(): void protected function d3AddDebugBarComponent(): void
{ {
$userComponentNames = Registry::getConfig()->getConfigParam('aUserComponentNames'); if ($this->d3CanActivateDebugBar()) {
$d3CmpName = DebugBarComponent::class; $userComponentNames = Registry::getConfig()->getConfigParam( 'aUserComponentNames' );
$blDontUseCache = 1; $d3CmpName = DebugBarComponent::class;
$blDontUseCache = 1;
if (!is_array($userComponentNames)) { if ( ! is_array( $userComponentNames ) ) {
$userComponentNames = []; $userComponentNames = [];
} }
if (!in_array($d3CmpName, array_keys($userComponentNames))) { if ( ! in_array( $d3CmpName, array_keys( $userComponentNames ) ) ) {
$userComponentNames[$d3CmpName] = $blDontUseCache; $userComponentNames[ $d3CmpName ] = $blDontUseCache;
Registry::getConfig()->setConfigParam('aUserComponentNames', $userComponentNames); Registry::getConfig()->setConfigParam( 'aUserComponentNames', $userComponentNames );
}
} }
} }
/**
* @return bool
*/
protected function d3CanActivateDebugBar(): bool
{
return false === isAdmin();
}
public function __destruct() public function __destruct()
{ {
global $debugBarSet; global $debugBarSet;