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,6 +42,7 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
*/
public function d3DebugBarSetErrorHandler()
{
if ($this->d3CanActivateDebugBar()) {
set_error_handler( function( $severity, $message, $file, $line ) {
if ( ! ( error_reporting() & $severity ) ) {
// This error code is not included in error_reporting.
@ -56,17 +57,20 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
throw new ErrorException( $message, 0, $severity, $file, $line );
} );
}
}
/**
* @return void
*/
protected function d3DebugBarSetExceptionHandler(): void
{
if ($this->d3CanActivateDebugBar()) {
set_exception_handler( [
new DebugBarExceptionHandler(),
'handleUncaughtException'
] );
}
}
/**
* @param $messsage
@ -89,6 +93,7 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
*/
protected function d3AddDebugBarComponent(): void
{
if ($this->d3CanActivateDebugBar()) {
$userComponentNames = Registry::getConfig()->getConfigParam( 'aUserComponentNames' );
$d3CmpName = DebugBarComponent::class;
$blDontUseCache = 1;
@ -102,6 +107,15 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
Registry::getConfig()->setConfigParam( 'aUserComponentNames', $userComponentNames );
}
}
}
/**
* @return bool
*/
protected function d3CanActivateDebugBar(): bool
{
return false === isAdmin();
}
public function __destruct()
{