fix not existing component issue in admin panels login controller

This commit is contained in:
Daniel Seifert 2022-08-15 15:44:51 +02:00
parent 4b47e5ddb6
commit ff606efef3
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
2 changed files with 41 additions and 30 deletions

View File

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

View File

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