Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save proudcommerce/602ab33c23a1546588266812ed72ac30 to your computer and use it in GitHub Desktop.
Save proudcommerce/602ab33c23a1546588266812ed72ac30 to your computer and use it in GitHub Desktop.
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;
}
}
@suabo
Copy link

suabo commented Oct 14, 2020

Thx 4 Sharing

@alfredbez
Copy link

@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