Comparer les révisions

..

19 Révisions

Auteur SHA1 Message Date
cdf21175e5
fix sensitive settings type 2025-04-03 22:33:38 +02:00
b58391c02c improve code style 2025-03-25 09:20:39 +01:00
153ce3f5ec list template variables in collector as expandable structure 2025-03-24 10:53:07 +01:00
f3b9c89cc9 don't show debug bar in shop productive mode 2025-03-24 10:51:23 +01:00
556379bc46 complete configuration collector by module settings, improve displaying 2025-03-24 10:46:25 +01:00
8f0c912dca don't use D3 logo graphic in module name 2025-03-24 10:44:53 +01:00
ce035a9742 refactor shop collector 2025-03-24 10:44:03 +01:00
6534af14c3 remove unused Smarty collector 2025-03-24 10:42:54 +01:00
29940a97d1 fix typo 2025-03-24 10:40:55 +01:00
b02708f5ae update documentation 2025-03-24 08:43:16 +01:00
843c49e137 show controller template variables before global 2025-03-24 08:17:27 +01:00
16c524bd1a get Doctrine connection from DIC 2025-03-24 08:17:27 +01:00
f54713acb8 add template variables collector as a replacement for the former Smarty collector 2025-03-24 08:17:27 +01:00
1309aa5976 add Twig collector 2025-03-24 08:17:27 +01:00
f3a7b00ea8 update debugbar package 2025-03-24 08:17:26 +01:00
1ead3a427e make installable in OXID7 2025-03-24 08:16:42 +01:00
0033d52f8f
bump debugbar library to 1.20 because of relevant core changes 2025-03-23 13:04:24 +01:00
ab7e4fa595
make SmartyCollector class compatible to parent class 2025-03-23 12:52:57 +01:00
8dab80e4d9
make installable in OXID 6.5.x 2025-03-23 12:39:18 +01:00
31 fichiers modifiés avec 362 ajouts et 284 suppressions

Voir le fichier

@ -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);

Voir le fichier

@ -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();

Voir le fichier

@ -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();
}
/**

Voir le fichier

@ -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
*/

Voir le fichier

@ -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;

Voir le fichier

@ -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
*

Voir le fichier

@ -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,49 +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;
/**
* @var bool
*/
protected $useHtmlVarDumper = false;
/**
* Sets a flag indicating whether the Symfony HtmlDumper will be used to dump variables for
* rich variable rendering.
*
* @param bool $value
* @return $this
*/
public function useHtmlVarDumper(bool $value = true): SmartyCollector
public function __construct(protected array $templateVariables)
{
$this->useHtmlVarDumper = $value;
return $this;
}
/**
* Indicates whether the Symfony HtmlDumper will be used to dump variables for rich variable
* rendering.
*
* @return bool
*/
public function isHtmlVarDumperUsed(): bool
{
return $this->useHtmlVarDumper;
}
/**
* @param Smarty $smarty
*/
public function __construct(Smarty $smarty)
{
$this->smarty = $smarty;
}
/**
@ -71,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()) {
@ -89,7 +52,7 @@ class SmartyCollector extends DataCollector implements Renderable
*/
public function getName(): string
{
return 'smarty';
return 'template_variables';
}
/**
@ -101,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,
],
];

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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]];

Voir le fichier

@ -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);

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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)
{

Voir le fichier

@ -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);
}
}

Voir le fichier

@ -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

Voir le fichier

@ -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

Voir le fichier

@ -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
*

Voir le fichier

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

Voir le fichier

@ -25,34 +25,23 @@
"GPL-3.0-or-later"
],
"require": {
"php": ">=7.3",
"oxid-esales/oxideshop-ce": "6.8 - 6.13",
"maximebf/debugbar": "^1.18",
"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"
}
}

Voir le fichier

@ -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' => '',

Fichier binaire non affiché.

Avant

Largeur:  |  Hauteur:  |  Taille: 71 KiB

BIN
screenshot.png Fichier normal

Fichier binaire non affiché.

Après

Largeur:  |  Hauteur:  |  Taille: 49 KiB

Voir le fichier

@ -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' ]