Fix for OXID 6.2 circular reference service problems
# thx to alfred (https://github.com/alfredbez) for sharing | |
# add to modules/functions.php | |
use Monolog\Logger; | |
use Monolog\Handler\StreamHandler; | |
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; | |
use Psr\Log\LoggerInterface; | |
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; | |
function getLogger() { | |
$loggerServiceName = LoggerInterface::class; | |
try { | |
$container = ContainerFactory::getInstance()->getContainer(); | |
return $container->get($loggerServiceName); | |
} catch (ServiceCircularReferenceException $exception) { | |
if (strpos($exception->getMessage(), $loggerServiceName) !== false) { | |
$logger = new Logger('OXID Logger'); | |
$logger->pushHandler(new StreamHandler(OX_LOG_FILE, Logger::ERROR)); | |
$logger->critical('Not able to load logger from container'); | |
return $logger; | |
} | |
throw $exception; | |
} | |
} |
This comment has been minimized.
This comment has been minimized.
@proudcommerce & @suabo FYI: There is also an open Pull-Request to fix this directly in the core: OXID-eSales/oxideshop_ce#810 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Thx 4 Sharing