16 Commits

31 changed files with 362 additions and 254 deletions

View File

@ -1,13 +1,35 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;
declare(strict_types=1);
$finder = PhpCsFixer\Finder::create()->in(__DIR__);
$header = <<<EOF
Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
For the full copyright and license information, please view
the LICENSE file that was distributed with this source code.
https://www.d3data.de
@copyright (C) D3 Data Development (Inh. Thomas Dartsch)
@author D3 Data Development - Daniel Seifert <info@shopmodule.com>
@link https://www.oxidmodule.com
EOF;
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PHP73Migration' => true,
'@PSR12' => true
])
->setFinder($finder)
;
return $config->setRules(
[
'@PHP80Migration' => true,
'@PSR12' => true,
'header_comment' => [
'comment_type' => 'PHPDoc',
'header' => $header,
'location' => 'after_open',
'separate' => 'both',
],
'php_unit_test_class_requires_covers' => true,
'doctrine_annotation_indentation' => true,
]
)
->setFinder($finder);

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -19,11 +21,12 @@ use D3\DebugBar\Application\Models\AvailabilityCheck;
use D3\DebugBar\Application\Models\Collectors\OxidConfigCollector;
use D3\DebugBar\Application\Models\Collectors\OxidShopCollector;
use D3\DebugBar\Application\Models\Collectors\OxidVersionCollector;
use D3\DebugBar\Application\Models\Collectors\SmartyCollector;
use D3\DebugBar\Application\Models\Collectors\TemplateVariablesCollector;
use D3\DebugBar\Application\Models\Exceptions\UnavailableException;
use D3\DebugBar\Application\Models\TimeDataCollectorHandler;
use DebugBar\Bridge\DoctrineCollector;
use DebugBar\Bridge\MonologCollector;
use DebugBar\Bridge\NamespacedTwigProfileCollector;
use DebugBar\DataCollector\ExceptionsCollector;
use DebugBar\DataCollector\MemoryCollector;
use DebugBar\DataCollector\MessagesCollector;
@ -37,18 +40,23 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Logging\DebugStack;
use Monolog\Logger;
use OxidEsales\Eshop\Core\Controller\BaseController;
use OxidEsales\Eshop\Core\DatabaseProvider;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Database\ConnectionProviderInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridge;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
use OxidEsales\Twig\TwigEngine;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use ReflectionClass;
use ReflectionException;
use Twig\Profiler\Profile;
class DebugBarComponent extends BaseController
{
/** @var DebugBar|null */
protected $debugBar = null;
/** @var JavascriptRenderer */
protected $debugBarRenderer;
protected DebugBar|null $debugBar = null;
protected null|JavascriptRenderer $debugBarRenderer = null;
/**
* Marking object as component
@ -57,9 +65,9 @@ class DebugBarComponent extends BaseController
protected $_blIsComponent = true;
/**
* @throws ContainerExceptionInterface
* @throws DebugBarException
* @throws DatabaseConnectionException
* @throws ReflectionException
* @throws NotFoundExceptionInterface
*/
public function __construct()
{
@ -89,27 +97,50 @@ class DebugBarComponent extends BaseController
/**
* @return DoctrineCollector
* @throws ReflectionException
* @throws ContainerExceptionInterface
* @throws DebugBarException
* @throws DatabaseConnectionException
* @throws NotFoundExceptionInterface
*/
public function getDoctrineCollector(): DoctrineCollector
{
$db = DatabaseProvider::getDb();
$debugStack = new DebugStack();
/** @var Connection $connection */
$connection = $this->getNonPublicProperty($db, 'connection');
$connection = ContainerFactory::getInstance()->getContainer()->get(ConnectionProviderInterface::class)->get();
$debugStack = new DebugStack();
$connection->getConfiguration()->setSQLLogger($debugStack);
return new DoctrineCollector($debugStack);
}
/**
* @return SmartyCollector
* @return TemplateVariablesCollector
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getSmartyCollector(): SmartyCollector
public function getTemplateVariablesCollector(): TemplateVariablesCollector
{
$smarty = Registry::getUtilsView()->getSmarty();
return new SmartyCollector($smarty);
/** @var TemplateRenderer $renderer */
$renderer = ContainerFactory::getInstance()->getContainer()
->get(TemplateRendererBridgeInterface::class)
->getTemplateRenderer();
$templateEngine = $renderer->getTemplateEngine();
return new TemplateVariablesCollector(
array_merge(
Registry::getConfig()->getActiveView()->getViewData(),
$templateEngine->getGlobals()
)
);
}
/**
* @return NamespacedTwigProfileCollector
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getTwigCollector(): NamespacedTwigProfileCollector
{
/** @var Profile $profile */
$profile = ContainerFactory::getInstance()->getContainer()->get(Profile::class);
return new NamespacedTwigProfileCollector($profile);
}
/**
@ -136,27 +167,12 @@ class DebugBarComponent extends BaseController
return oxNew(OxidVersionCollector::class);
}
/**
* @param object $object
* @param string $propName
*
* @return mixed
* @throws ReflectionException
*/
protected function getNonPublicProperty(object $object, string $propName)
{
$reflection = new ReflectionClass($object);
$property = $reflection->getProperty($propName);
$property->setAccessible(true);
return $property->getValue($object);
}
/**
* @param DebugBar $debugbar
* @return void
* @throws DatabaseConnectionException
* @throws ContainerExceptionInterface
* @throws DebugBarException
* @throws ReflectionException
* @throws NotFoundExceptionInterface
*/
public function addCollectors(DebugBar $debugbar): void
{
@ -171,7 +187,18 @@ class DebugBarComponent extends BaseController
// add custom collectors
$debugbar->addCollector($this->getOxidShopCollector());
$debugbar->addCollector($this->getOxidConfigCollector());
$debugbar->addCollector($this->getSmartyCollector());
$debugbar->addCollector($this->getTemplateVariablesCollector());
/** @var TemplateRendererBridge $templateRendererBridge */
$templateRendererBridge = ContainerFactory::getInstance()->getContainer()->get(TemplateRendererBridgeInterface::class);
switch (get_class($templateRendererBridge->getTemplateRenderer()->getTemplateEngine())) {
case TwigEngine::class:
$debugbar->addCollector($this->getTwigCollector());
break;
default:
dumpvar(get_class($templateRendererBridge->getTemplateRenderer()->getTemplateEngine()));
}
$debugbar->addCollector($this->getMonologCollector());
$debugbar->addCollector($this->getDoctrineCollector());
$debugbar->addCollector($this->getOxidVersionCollector());
@ -179,8 +206,10 @@ class DebugBarComponent extends BaseController
/**
* @return void
* @throws UnavailableException
* @throws ReflectionException
*/
public function addTimelineMessures(): void
public function addTimelineMeasures(): void
{
if (false === $this->debugBar instanceof DebugBar) {
throw new UnavailableException();

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -15,7 +17,6 @@ declare(strict_types=1);
namespace D3\DebugBar\Application\Models;
use OxidEsales\Eshop\Application\Model\User;
use OxidEsales\Eshop\Core\Registry;
class AvailabilityCheck
@ -28,7 +29,7 @@ class AvailabilityCheck
return !isAdmin() && (
Registry::getConfig()->getShopConfVar('d3debugbar_showForAdminUsersOnly') != true ||
self::userIsMallAdmin()
);
) && !Registry::getConfig()->isProductiveMode();
}
/**

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -20,37 +22,64 @@ use DebugBar\DataCollector\Renderable;
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\ConfigFile;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ShopConfigurationDaoBridge;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ShopConfigurationDaoBridgeInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use ReflectionClass;
use ReflectionException;
class OxidConfigCollector extends DataCollector implements Renderable
{
/** @var Config */
protected $config;
public const HIDDEN_TEXT = '[hidden]';
/** @var array */
protected $configVars = [];
/**
* @var bool
*/
protected $useHtmlVarDumper = false;
protected array $configVars = [];
/**
* @param Config $config
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public function __construct(Config $config)
{
$config->init();
$this->config = $config;
$this->configVars = array_merge(
(array) $this->getNonPublicProperty($this->config, '_aConfigParams'),
Registry::get(ConfigFile::class)->getVars()
);
$this->configVars['config table'] = (array) $this->getNonPublicProperty($config, '_aConfigParams');
$this->configVars['config file'] = Registry::get(ConfigFile::class)->getVars();
$this->configVars = array_merge($this->configVars, $this->getModuleSettings());
$this->sanitizeCriticalProperties();
$this->useHtmlVarDumper(false);
}
/**
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function getModuleSettings(): array
{
$container = ContainerFactory::getInstance()->getContainer();
/** @var ShopConfigurationDaoBridge $shopConfigurationDaoBridge */
$shopConfigurationDaoBridge = $container->get(ShopConfigurationDaoBridgeInterface::class);
$shopConfiguration = $shopConfigurationDaoBridge->get();
$moduleSettings = [];
foreach ($shopConfiguration->getModuleConfigurations() as $moduleConfiguration) {
foreach ($moduleConfiguration->getModuleSettings() as $setting) {
$moduleSettings[$moduleConfiguration->getId()][$setting->getName()] =
strtolower($setting->getType()) == 'password' ?
self::HIDDEN_TEXT :
$setting->getValue();
}
}
return $moduleSettings;
}
/**
@ -62,11 +91,13 @@ class OxidConfigCollector extends DataCollector implements Renderable
$specific = ['sSerialNr', 'aSerials', 'dbPwd'];
$search = array_merge($generic, $specific);
array_walk($this->configVars, function ($item, $key) use ($search) {
if (in_array($key, $search)) {
$this->configVars[$key] = '[hidden]';
}
});
foreach ($this->configVars as $group => $values) {
array_walk($this->configVars[$group], function ($item, $key) use ($group, $search) {
if (in_array($key, $search)) {
$this->configVars[$group][ $key ] = self::HIDDEN_TEXT;
}
});
}
}
/**
@ -76,7 +107,7 @@ class OxidConfigCollector extends DataCollector implements Renderable
* @return mixed
* @throws ReflectionException
*/
protected function getNonPublicProperty(object $object, string $propName)
protected function getNonPublicProperty(object $object, string $propName): mixed
{
$reflection = new ReflectionClass($object);
$property = $reflection->getProperty($propName);
@ -112,17 +143,6 @@ class OxidConfigCollector extends DataCollector implements Renderable
return ['vars' => $data, 'count' => count($data)];
}
/**
* Indicates whether the Symfony HtmlDumper will be used to dump variables for rich variable
* rendering.
*
* @return bool
*/
public function isHtmlVarDumperUsed(): bool
{
return $this->useHtmlVarDumper;
}
/**
* @return array
*/

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -20,28 +22,21 @@ use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use Exception;
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\Module\Module;
use OxidEsales\Eshop\Core\ShopVersion;
use OxidEsales\Eshop\Core\Theme;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ShopConfigurationDaoBridge;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ShopConfigurationDaoBridgeInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration;
use OxidEsales\Facts\Facts;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class OxidShopCollector extends DataCollector implements Renderable
{
/** @var Config */
protected $config;
protected Config $config;
/** @var array */
protected $configVars = [];
/**
* @var bool
*/
protected $useHtmlVarDumper = true;
protected array $configVars = [];
/**
* @throws ContainerExceptionInterface
@ -57,11 +52,11 @@ class OxidShopCollector extends DataCollector implements Renderable
$parentThemeId = $parent ? $parent->getId() : '--';
$moduleList = $this->getInstalledModules();
$list = [];
array_walk(
$moduleList,
function (Module &$module) {
$str = trim(strip_tags($module->getTitle())).' - '.$module->getInfo('version').' ';
$module = $str;
function (ModuleConfiguration $module) use (&$list) {
$list[] = trim(strip_tags(current($module->getTitle()))).' - '.$module->getVersion();
}
);
@ -71,8 +66,10 @@ class OxidShopCollector extends DataCollector implements Renderable
'CE Version:' => InstalledVersions::getVersion('oxid-esales/oxideshop-ce'),
'Theme:' => $theme->getActiveThemeId(),
'Parent Theme:' => $parentThemeId,
'Modules:' => implode(chr(10), $moduleList),
'Modules:' => $list,
];
$this->useHtmlVarDumper(false);
}
/**
@ -103,17 +100,6 @@ class OxidShopCollector extends DataCollector implements Renderable
return ['vars' => $data, 'count' => count($data)];
}
/**
* Indicates whether the Symfony HtmlDumper will be used to dump variables for rich variable
* rendering.
*
* @return bool
*/
public function isHtmlVarDumperUsed(): bool
{
return $this->useHtmlVarDumper;
}
/**
* @return array
*/
@ -133,7 +119,7 @@ class OxidShopCollector extends DataCollector implements Renderable
}
/**
* @return array
* @return ModuleConfiguration[]
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
@ -147,13 +133,13 @@ class OxidShopCollector extends DataCollector implements Renderable
$modules = [];
foreach ($shopConfiguration->getModuleConfigurations() as $moduleConfiguration) {
$module = oxNew(Module::class);
$module->load($moduleConfiguration->getId());
$modules[] = $module;
$modules[] = $moduleConfiguration;
}
/** @var $a ModuleConfiguration */
/** @var $b ModuleConfiguration */
usort($modules, function ($a, $b) {
return strcmp($a->getTitle(), $b->getTitle());
return strcmp(current($a->getTitle()), current($b->getTitle()));
});
return $modules;

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*

View File

@ -1,12 +1,13 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (c) 2016 Dmitry Kosenkov
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
@ -19,19 +20,11 @@ namespace D3\DebugBar\Application\Models\Collectors;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use OxidEsales\Eshop\Core\Registry;
use Smarty;
class SmartyCollector extends DataCollector implements Renderable
class TemplateVariablesCollector extends DataCollector implements Renderable
{
/** @var Smarty */
protected $smarty;
/**
* @param Smarty $smarty
*/
public function __construct(Smarty $smarty)
public function __construct(protected array $templateVariables)
{
$this->smarty = $smarty;
}
/**
@ -41,7 +34,7 @@ class SmartyCollector extends DataCollector implements Renderable
{
$data = ['current view template' => Registry::getConfig()->getTopActiveView()->getTemplateName()];
$vars = $this->smarty->get_template_vars();
$vars = $this->templateVariables;
foreach ($vars as $idx => $var) {
if ($this->isHtmlVarDumperUsed()) {
@ -59,7 +52,7 @@ class SmartyCollector extends DataCollector implements Renderable
*/
public function getName(): string
{
return 'smarty';
return 'template_variables';
}
/**
@ -71,14 +64,14 @@ class SmartyCollector extends DataCollector implements Renderable
? "PhpDebugBar.Widgets.HtmlVariableListWidget"
: "PhpDebugBar.Widgets.VariableListWidget";
return [
"smarty" => [
"template_variables" => [
"icon" => "file-text",
"widget" => $widget,
"map" => "smarty.vars",
"map" => "template_variables.vars",
"default" => "{}",
],
"smarty:badge" => [
"map" => "smarty.count",
"template_variables:badge" => [
"map" => "template_variables.count",
"default" => 0,
],
];

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -19,8 +21,7 @@ use DebugBar\DataCollector\TimeDataCollector;
class TimeDataCollectorHandler
{
/** @var TimeDataCollector */
private static $instance = null;
private static TimeDataCollector|null $instance = null;
/**
* @return TimeDataCollector

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -52,20 +54,14 @@ class DebugBarErrorHandler
[ $file, $line ] = $smartyTemplate;
}
switch ($severity) {
case E_CORE_ERROR:
throw new CoreErrorException($message, 0, $severity, $file, $line);
case E_COMPILE_ERROR:
throw new CompileErrorException($message, 0, $severity, $file, $line);
case E_USER_ERROR:
throw new UserErrorException($message, 0, $severity, $file, $line);
case E_PARSE:
throw new ParseException($message, 0, $severity, $file, $line);
case E_ERROR:
throw new ErrorException($message, 0, $severity, $file, $line);
default:
$this->handleUnregisteredErrorTypes($message, $severity, $file, $line);
}
throw match ($severity) {
E_CORE_ERROR => new CoreErrorException($message, 0, $severity, $file, $line),
E_COMPILE_ERROR => new CompileErrorException($message, 0, $severity, $file, $line),
E_USER_ERROR => new UserErrorException($message, 0, $severity, $file, $line),
E_PARSE => new ParseException($message, 0, $severity, $file, $line),
E_ERROR => new ErrorException($message, 0, $severity, $file, $line),
default => $this->handleUnregisteredErrorTypes($message, $severity, $file, $line),
};
}
/**
@ -75,7 +71,7 @@ class DebugBarErrorHandler
protected function getSmartyTemplateLocationFromError(string $messsage): ?array
{
if (stristr($messsage, 'Smarty error: [in ')) {
$start = strpos($messsage, '[')+1;
$start = strpos($messsage, '[') + 1;
$end = strpos($messsage, ']');
$parts = explode(' ', substr($messsage, $start, $end - $start));
return [Registry::getConfig()->getTemplateDir(isAdmin()).$parts[1], (int) $parts[3]];

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -20,11 +22,10 @@ use D3\DebugBar\Application\Models\AvailabilityCheck;
use D3\DebugBar\Application\Models\Exceptions\UnavailableException;
use DebugBar\DataCollector\ExceptionsCollector;
use DebugBar\DebugBarException;
use OxidEsales\Eshop\Core\ConfigFile;
use OxidEsales\Eshop\Core\Exception\ExceptionHandler;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Framework\Logger\LoggerServiceFactory;
use OxidEsales\EshopCommunity\Internal\Transition\Utility\Context;
use ReflectionException;
use Throwable;
class DebugBarExceptionHandler
@ -33,27 +34,25 @@ class DebugBarExceptionHandler
* Handler for uncaught exceptions.
*
* @param Throwable $exception exception object
*
* @return void
* @throws ReflectionException
*/
public function handleUncaughtException(Throwable $exception): void
{
try {
/** @var int $debugMode */
$debugMode = Registry::get(ConfigFile::class)->getVar('iDebug');
$defaultExceptionHandler = new ExceptionHandler($debugMode);
$defaultExceptionHandler->writeExceptionToLog($exception);
} catch (Throwable $loggerException) {
Registry::getLogger()->error(
$exception->getMessage(),
[$exception]
);
} catch (Throwable) {
/**
* It's not possible to get the logger from the DI container.
* Try again to log original exception (without DI container) in order to show the root cause of a problem.
*/
try {
$loggerServiceFactory = new LoggerServiceFactory(new Context());
$logger = $loggerServiceFactory->getLogger();
$logger->error($exception->getTraceAsString());
} catch (Throwable $throwableWithoutPossibilityToWriteToLogFile) {
// It's not possible to log because e.g. the log file is not writable.
}
$loggerServiceFactory = new LoggerServiceFactory(new Context());
$logger = $loggerServiceFactory->getLogger();
$logger->error($exception);
}
if (AvailabilityCheck::isAvailable() && AvailabilityCheck::ifDebugBarNotSet()) {
@ -66,23 +65,23 @@ class DebugBarExceptionHandler
$excCollector->addThrowable($exception);
echo <<<HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
HTML;
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
HTML;
echo $debugBarComponent->getRenderer()->renderHead();
$debugBarComponent->addTimelineMessures();
$debugBarComponent->addTimelineMeasures();
echo <<<HTML
</head>
<body>
HTML;
</head>
<body>
HTML;
AvailabilityCheck::markDebugBarAsSet();
echo $debugBarComponent->getRenderer()->render();
echo <<<HTML
</body>
</html>
HTML;
</body>
</html>
HTML;
} catch (DebugBarException|UnavailableException $e) {
Registry::getLogger()->error($e->getMessage());
Registry::getUtilsView()->addErrorToDisplay($e);

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -18,9 +20,11 @@ namespace D3\DebugBar\Modules\Core;
use D3\DebugBar\Application\Component\DebugBarComponent;
use D3\DebugBar\Application\Models\AvailabilityCheck;
use D3\DebugBar\Application\Models\DebugBarHandler;
use D3\DebugBar\Application\Models\Exceptions\UnavailableException;
use D3\DebugBar\Core\DebugBarExceptionHandler;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry;
use ReflectionException;
use Throwable;
class ShopControl_DebugBar extends ShopControl_DebugBar_parent
@ -39,8 +43,11 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
/**
* @param string|null $controllerKey
* @param string|null $function
* @param array $parameters
* @param array $viewsChain
* @param array|null $parameters
* @param array|null $viewsChain
*
* @throws UnavailableException
* @throws ReflectionException
*/
public function start($controllerKey = null, $function = null, $parameters = null, $viewsChain = null)
{
@ -55,7 +62,7 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
if ($debugBarComponent) {
AvailabilityCheck::markDebugBarAsSet();
echo $debugBarComponent->getRenderer()->renderHead();
$debugBarComponent->addTimelineMessures();
$debugBarComponent->addTimelineMeasures();
echo $debugBarComponent->getRenderer()->render();
}
}
@ -63,7 +70,9 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
/**
* @param Throwable $exception
*
* @return void
* @throws ReflectionException
*/
protected function debugBarHandleException(Throwable $exception): void
{
@ -73,6 +82,8 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
/**
* @param StandardException $exception
*
* @throws ReflectionException
*/
protected function _handleSystemException($exception)
{
@ -81,6 +92,8 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
/**
* @param StandardException $exception
*
* @throws ReflectionException
*/
protected function _handleCookieException($exception)
{
@ -89,6 +102,8 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
/**
* @param StandardException $exception
*
* @throws ReflectionException
*/
protected function _handleBaseException($exception)
{

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -81,7 +83,7 @@ function stopProfile(string $sProfileName): void
* @throws DebugBarException
* @return void
*/
function debugVar($mVar, bool $blToFile = false): void
function debugVar(mixed $mVar, bool $blToFile = false): void
{
if ($blToFile) {
$out = var_export($mVar, true);
@ -106,10 +108,9 @@ function debugVar($mVar, bool $blToFile = false): void
/** @var MessagesCollector $messages */
$messages = $debugBarComponent->getDebugBar()->getCollector('messages');
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
//$location = $trace[1]['class'] . '::' . $trace[1]['function']. '(' . $trace[0]['line'] . ')';
$location = $trace[1]['class'] . '::' . $trace[1]['function'];
$messages->addMessage($mVar, $location);
} catch (UnavailableException $e) {
} catch (UnavailableException) {
dumpVar($mVar, $blToFile);
}
}

View File

@ -1,3 +1,7 @@
![stability mature](https://img.shields.io/badge/stability-mature-008000.svg)
[![latest tag](https://img.shields.io/packagist/v/d3/oxid-debugbar?label=release)](https://packagist.org/packages/d3/oxid-debugbar)
![License](https://img.shields.io/packagist/l/d3/oxid-debugbar)
[![deutsche Version](https://logos.oxidmodule.com/de2_xs.svg)](README.md)
[![english version](https://logos.oxidmodule.com/en2_xs.svg)](README.en.md)
@ -5,7 +9,7 @@
The debug bar enables the display of relevant debug information in the shop frontend.
![screenshot](screenshot.jpg "Screenshot")
![screenshot](screenshot.png "Screenshot")
## Table of content
@ -25,14 +29,14 @@ Please enter the following section in the `composer.json` of your project:
```
"extra": {
"ajgl-symlinks": {
"maximebf/debugbar": {
"php-debugbar/php-debugbar": {
"src/DebugBar/Resources": "source/out/debugbar"
}
},
"enable-patching": "true",
"patches": {
"oxid-esales/oxideshop-ce": {
"Add overridable functions for advanced profiling in Debug Bar": "https://git.d3data.de/D3Public/DebugBar/raw/branch/patches/overridablefunctions.patch"
"Add overridable functions for advanced profiling in Debug Bar": "https://git.d3data.de/D3Public/DebugBar/raw/branch/patches/overridablefunctions_2.0.patch"
}
}
}
@ -41,18 +45,24 @@ Please enter the following section in the `composer.json` of your project:
Open a command line and navigate to the root directory of the shop (parent directory of source and vendor). Execute the following command. Adapt the path details to your installation environment.
```bash
php composer require d3/oxid-debugbar:^1.0
php composer require d3/oxid-debugbar:^2.0
```
If necessary, please confirm that you allow `composer-symlinker` and `composer-patches` to execute code.
```bash
rm -rf vendor/oxid-esales/oxideshop-ce
php composer install
php composer update --lock
```
Have the files of the package `oxid-esales/oxideshop-ce` overwritten.
Activate the module in Shopadmin under "Extensions -> Modules".
## How to use
__Please note that the DebugBar contains security-relevant information. It should therefore not be activated under any circumstances in a freely accessible installation.__
__Please note that the DebugBar contains security-relevant information. It should therefore never be activated in a public installation__.
The DebugBar displays the following tabs:
- Messages
@ -65,8 +75,10 @@ The DebugBar displays the following tabs:
shows basic shop information (edition, versions, theme information)
- Configuration
provides all configuration settings of the shop from database and config files
- Smarty
- Template variables
lists all variables of the template engine that are available on the current shop page
- Twig
shows Twig internal profiling (only when using the Twig Template Engine)
- Monolog
lists all log messages passed to the Monolog Logger
- Database

View File

@ -1,3 +1,7 @@
![stability mature](https://img.shields.io/badge/stability-mature-008000.svg)
[![latest tag](https://img.shields.io/packagist/v/d3/oxid-debugbar?label=release)](https://packagist.org/packages/d3/oxid-debugbar)
![License](https://img.shields.io/packagist/l/d3/oxid-debugbar)
[![deutsche Version](https://logos.oxidmodule.com/de2_xs.svg)](README.md)
[![english version](https://logos.oxidmodule.com/en2_xs.svg)](README.en.md)
@ -5,7 +9,7 @@
Die Debug Bar ermöglicht die Darstellung relevanter Debuginformationen im Shopfrontend.
![screenshot](screenshot.jpg "Screenshot")
![screenshot](screenshot.png "Screenshot")
## Inhaltsverzeichnis
@ -25,14 +29,14 @@ Bitte tragen Sie den folgenden Abschnitt in die `composer.json` Ihres Projektes
```
"extra": {
"ajgl-symlinks": {
"maximebf/debugbar": {
"php-debugbar/php-debugbar": {
"src/DebugBar/Resources": "source/out/debugbar"
}
},
"enable-patching": "true",
"patches": {
"oxid-esales/oxideshop-ce": {
"Add overridable functions for advanced profiling in Debug Bar": "https://git.d3data.de/D3Public/DebugBar/raw/branch/patches/overridablefunctions.patch"
"Add overridable functions for advanced profiling in Debug Bar": "https://git.d3data.de/D3Public/DebugBar/raw/branch/patches/overridablefunctions_2.0.patch"
}
}
}
@ -41,11 +45,17 @@ Bitte tragen Sie den folgenden Abschnitt in die `composer.json` Ihres Projektes
Ă–ffnen Sie eine Kommandozeile und navigieren Sie zum Stammverzeichnis des Shops (Elternverzeichnis von source und vendor). FĂĽhren Sie den folgenden Befehl aus. Passen Sie die Pfadangaben an Ihre Installationsumgebung an.
```bash
php composer require d3/oxid-debugbar:^1.0
php composer require d3/oxid-debugbar:^2.0
```
Sofern nötig, bestätigen Sie bitte, dass Sie `composer-symlinker` und `composer-patches` erlauben, Code auszuführen.
```bash
rm -rf vendor/oxid-esales/oxideshop-ce
php composer install
php composer update --lock
```
Lassen Sie die Dateien des Paketes `oxid-esales/oxideshop-ce` ĂĽberschreiben.
Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module".
@ -65,8 +75,10 @@ Die DebugBar stellt folgende Tabs dar:
zeigt grundlegende Shopinformationen (Edition, Versionen, Themeinformationen)
- Configuration
stellt alle Konfigurationseinstellungen des Shops aus Datenbank und config-Dateien zur VerfĂĽgung
- Smarty
- Template Variablen
listet alle Variablen der Template-Engine, die auf der aktuellen Shopseite zur VerfĂĽgung stehen
- Twig
zeigt Twig internes Profiling (nur bei Verwendung der Twig Template Engine)
- Monolog
listet alle an den Monolog Logger ĂĽbergebenen Lognachrichten
- Database

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*

View File

@ -2,4 +2,3 @@
- clear tpl cache button
- phpinfo() overview
- automatic switch between Smarty and Twig

View File

@ -25,34 +25,23 @@
"GPL-3.0-or-later"
],
"require": {
"php": ">=7.3",
"oxid-esales/oxideshop-ce": "^6.14",
"maximebf/debugbar": "^1.20",
"php": "^8.0",
"oxid-esales/oxideshop-ce": "7.0 - 7.2",
"php-debugbar/php-debugbar": "^2.1.6",
"ajgl/composer-symlinker": "^0.3.1",
"cweagans/composer-patches": "^1.7.2"
},
"require-dev": {
"php": "^7.4",
"phpunit/phpunit" : "^9.5",
"friendsofphp/php-cs-fixer": "^3.9",
"phpstan/phpstan": "^1.8"
},
"extra": {
"oxideshop": {
"blacklist-filter": [
"*.md",
"composer.json",
".php-cs-fixer.php",
"*.xml",
"*.neon",
"*.jpg"
],
"target-directory": "d3/debugbar"
}
},
"autoload": {
"psr-4": {
"D3\\DebugBar\\": "../../../source/modules/d3/debugbar"
"D3\\DebugBar\\": ""
}
},
"scripts": {
"php-cs-fixer": "./vendor/bin/php-cs-fixer fix --config=vendor/d3/oxid-debugbar/.php-cs-fixer.php"
}
}

View File

@ -1,8 +1,10 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -21,14 +23,13 @@ use OxidEsales\Eshop\Core\ShopControl;
$sMetadataVersion = '2.1';
$sModuleId = 'd3debugbar';
$logo = '<img src="https://logos.oxidmodule.com/d3logo.svg" alt="(D3)" style="height:1em;width:1em">';
/**
* Module information
*/
$aModule = [
'id' => $sModuleId,
'title' => $logo.' DebugBar',
'title' => '(D3) DebugBar',
'description' => [
'de' => '',
'en' => '',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@ -6,4 +6,12 @@ services:
Psr\Log\LoggerInterface:
class: Monolog\Logger
factory: ['@OxidEsales\EshopCommunity\Internal\Framework\Logger\Factory\LoggerFactoryInterface', 'create']
public: true
public: true
Twig\Profiler\Profile:
class: Twig\Profiler\Profile
public: true
shared: true
Twig\Extension\ProfilerExtension:
tags: [ 'twig.extension' ]