Vergelijk commits

..

No commits in common. "dev_2.x_OX7" and "main" have entirely different histories.

31 gewijzigde bestanden met toevoegingen van 285 en 363 verwijderingen

Bestand weergeven

@ -1,35 +1,13 @@
<?php
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;
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;
$config = new PhpCsFixer\Config();
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);
return $config->setRules([
'@PHP73Migration' => true,
'@PSR12' => true
])
->setFinder($finder)
;

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -21,12 +19,11 @@ 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\TemplateVariablesCollector;
use D3\DebugBar\Application\Models\Collectors\SmartyCollector;
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;
@ -40,23 +37,18 @@ 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
{
protected DebugBar|null $debugBar = null;
protected null|JavascriptRenderer $debugBarRenderer = null;
/** @var DebugBar|null */
protected $debugBar = null;
/** @var JavascriptRenderer */
protected $debugBarRenderer;
/**
* Marking object as component
@ -65,9 +57,9 @@ class DebugBarComponent extends BaseController
protected $_blIsComponent = true;
/**
* @throws ContainerExceptionInterface
* @throws DebugBarException
* @throws NotFoundExceptionInterface
* @throws DatabaseConnectionException
* @throws ReflectionException
*/
public function __construct()
{
@ -97,50 +89,27 @@ class DebugBarComponent extends BaseController
/**
* @return DoctrineCollector
* @throws ContainerExceptionInterface
* @throws ReflectionException
* @throws DebugBarException
* @throws NotFoundExceptionInterface
* @throws DatabaseConnectionException
*/
public function getDoctrineCollector(): DoctrineCollector
{
/** @var Connection $connection */
$connection = ContainerFactory::getInstance()->getContainer()->get(ConnectionProviderInterface::class)->get();
$db = DatabaseProvider::getDb();
$debugStack = new DebugStack();
/** @var Connection $connection */
$connection = $this->getNonPublicProperty($db, 'connection');
$connection->getConfiguration()->setSQLLogger($debugStack);
return new DoctrineCollector($debugStack);
}
/**
* @return TemplateVariablesCollector
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @return SmartyCollector
*/
public function getTemplateVariablesCollector(): TemplateVariablesCollector
public function getSmartyCollector(): SmartyCollector
{
/** @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);
$smarty = Registry::getUtilsView()->getSmarty();
return new SmartyCollector($smarty);
}
/**
@ -167,12 +136,27 @@ 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 ContainerExceptionInterface
* @throws DatabaseConnectionException
* @throws DebugBarException
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public function addCollectors(DebugBar $debugbar): void
{
@ -187,18 +171,7 @@ class DebugBarComponent extends BaseController
// add custom collectors
$debugbar->addCollector($this->getOxidShopCollector());
$debugbar->addCollector($this->getOxidConfigCollector());
$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->getSmartyCollector());
$debugbar->addCollector($this->getMonologCollector());
$debugbar->addCollector($this->getDoctrineCollector());
$debugbar->addCollector($this->getOxidVersionCollector());
@ -206,10 +179,8 @@ class DebugBarComponent extends BaseController
/**
* @return void
* @throws UnavailableException
* @throws ReflectionException
*/
public function addTimelineMeasures(): void
public function addTimelineMessures(): void
{
if (false === $this->debugBar instanceof DebugBar) {
throw new UnavailableException();

Bestand weergeven

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

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -22,64 +20,37 @@ 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
{
public const HIDDEN_TEXT = '[hidden]';
/** @var Config */
protected $config;
protected array $configVars = [];
/** @var array */
protected $configVars = [];
/**
* @var bool
*/
protected $useHtmlVarDumper = false;
/**
* @param Config $config
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws ReflectionException
*/
public function __construct(Config $config)
{
$config->init();
$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->config = $config;
$this->configVars = array_merge(
(array) $this->getNonPublicProperty($this->config, '_aConfigParams'),
Registry::get(ConfigFile::class)->getVars()
);
$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;
}
/**
@ -91,13 +62,11 @@ class OxidConfigCollector extends DataCollector implements Renderable
$specific = ['sSerialNr', 'aSerials', 'dbPwd'];
$search = array_merge($generic, $specific);
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;
}
});
}
array_walk($this->configVars, function ($item, $key) use ($search) {
if (in_array($key, $search)) {
$this->configVars[$key] = '[hidden]';
}
});
}
/**
@ -107,7 +76,7 @@ class OxidConfigCollector extends DataCollector implements Renderable
* @return mixed
* @throws ReflectionException
*/
protected function getNonPublicProperty(object $object, string $propName): mixed
protected function getNonPublicProperty(object $object, string $propName)
{
$reflection = new ReflectionClass($object);
$property = $reflection->getProperty($propName);
@ -143,6 +112,17 @@ 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
*/

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -22,21 +20,28 @@ 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
{
protected Config $config;
/** @var Config */
protected $config;
protected array $configVars = [];
/** @var array */
protected $configVars = [];
/**
* @var bool
*/
protected $useHtmlVarDumper = true;
/**
* @throws ContainerExceptionInterface
@ -52,11 +57,11 @@ class OxidShopCollector extends DataCollector implements Renderable
$parentThemeId = $parent ? $parent->getId() : '--';
$moduleList = $this->getInstalledModules();
$list = [];
array_walk(
$moduleList,
function (ModuleConfiguration $module) use (&$list) {
$list[] = trim(strip_tags(current($module->getTitle()))).' - '.$module->getVersion();
function (Module &$module) {
$str = trim(strip_tags($module->getTitle())).' - '.$module->getInfo('version').' ';
$module = $str;
}
);
@ -66,10 +71,8 @@ class OxidShopCollector extends DataCollector implements Renderable
'CE Version:' => InstalledVersions::getVersion('oxid-esales/oxideshop-ce'),
'Theme:' => $theme->getActiveThemeId(),
'Parent Theme:' => $parentThemeId,
'Modules:' => $list,
'Modules:' => implode(chr(10), $moduleList),
];
$this->useHtmlVarDumper(false);
}
/**
@ -100,6 +103,17 @@ 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
*/
@ -119,7 +133,7 @@ class OxidShopCollector extends DataCollector implements Renderable
}
/**
* @return ModuleConfiguration[]
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
@ -133,13 +147,13 @@ class OxidShopCollector extends DataCollector implements Renderable
$modules = [];
foreach ($shopConfiguration->getModuleConfigurations() as $moduleConfiguration) {
$modules[] = $moduleConfiguration;
$module = oxNew(Module::class);
$module->load($moduleConfiguration->getId());
$modules[] = $module;
}
/** @var $a ModuleConfiguration */
/** @var $b ModuleConfiguration */
usort($modules, function ($a, $b) {
return strcmp(current($a->getTitle()), current($b->getTitle()));
return strcmp($a->getTitle(), $b->getTitle());
});
return $modules;

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*

Bestand weergeven

@ -1,13 +1,12 @@
<?php
/**
* 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.
* 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
@ -20,11 +19,49 @@ namespace D3\DebugBar\Application\Models\Collectors;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;
use OxidEsales\Eshop\Core\Registry;
use Smarty;
class TemplateVariablesCollector extends DataCollector implements Renderable
class SmartyCollector extends DataCollector implements Renderable
{
public function __construct(protected array $templateVariables)
/** @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
{
$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;
}
/**
@ -34,7 +71,7 @@ class TemplateVariablesCollector extends DataCollector implements Renderable
{
$data = ['current view template' => Registry::getConfig()->getTopActiveView()->getTemplateName()];
$vars = $this->templateVariables;
$vars = $this->smarty->get_template_vars();
foreach ($vars as $idx => $var) {
if ($this->isHtmlVarDumperUsed()) {
@ -52,7 +89,7 @@ class TemplateVariablesCollector extends DataCollector implements Renderable
*/
public function getName(): string
{
return 'template_variables';
return 'smarty';
}
/**
@ -64,14 +101,14 @@ class TemplateVariablesCollector extends DataCollector implements Renderable
? "PhpDebugBar.Widgets.HtmlVariableListWidget"
: "PhpDebugBar.Widgets.VariableListWidget";
return [
"template_variables" => [
"smarty" => [
"icon" => "file-text",
"widget" => $widget,
"map" => "template_variables.vars",
"map" => "smarty.vars",
"default" => "{}",
],
"template_variables:badge" => [
"map" => "template_variables.count",
"smarty:badge" => [
"map" => "smarty.count",
"default" => 0,
],
];

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*

Bestand weergeven

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

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -54,14 +52,20 @@ class DebugBarErrorHandler
[ $file, $line ] = $smartyTemplate;
}
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),
};
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);
}
}
/**
@ -71,7 +75,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]];

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -22,10 +20,11 @@ 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
@ -34,25 +33,27 @@ class DebugBarExceptionHandler
* Handler for uncaught exceptions.
*
* @param Throwable $exception exception object
*
* @return void
* @throws ReflectionException
*/
public function handleUncaughtException(Throwable $exception): void
{
try {
Registry::getLogger()->error(
$exception->getMessage(),
[$exception]
);
} catch (Throwable) {
/** @var int $debugMode */
$debugMode = Registry::get(ConfigFile::class)->getVar('iDebug');
$defaultExceptionHandler = new ExceptionHandler($debugMode);
$defaultExceptionHandler->writeExceptionToLog($exception);
} catch (Throwable $loggerException) {
/**
* 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.
*/
$loggerServiceFactory = new LoggerServiceFactory(new Context());
$logger = $loggerServiceFactory->getLogger();
$logger->error($exception);
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.
}
}
if (AvailabilityCheck::isAvailable() && AvailabilityCheck::ifDebugBarNotSet()) {
@ -65,23 +66,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->addTimelineMeasures();
$debugBarComponent->addTimelineMessures();
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);

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* 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 +18,9 @@ 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
@ -43,11 +39,8 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
/**
* @param string|null $controllerKey
* @param string|null $function
* @param array|null $parameters
* @param array|null $viewsChain
*
* @throws UnavailableException
* @throws ReflectionException
* @param array $parameters
* @param array $viewsChain
*/
public function start($controllerKey = null, $function = null, $parameters = null, $viewsChain = null)
{
@ -62,7 +55,7 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
if ($debugBarComponent) {
AvailabilityCheck::markDebugBarAsSet();
echo $debugBarComponent->getRenderer()->renderHead();
$debugBarComponent->addTimelineMeasures();
$debugBarComponent->addTimelineMessures();
echo $debugBarComponent->getRenderer()->render();
}
}
@ -70,9 +63,7 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
/**
* @param Throwable $exception
*
* @return void
* @throws ReflectionException
*/
protected function debugBarHandleException(Throwable $exception): void
{
@ -82,8 +73,6 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
/**
* @param StandardException $exception
*
* @throws ReflectionException
*/
protected function _handleSystemException($exception)
{
@ -92,8 +81,6 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
/**
* @param StandardException $exception
*
* @throws ReflectionException
*/
protected function _handleCookieException($exception)
{
@ -102,8 +89,6 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
/**
* @param StandardException $exception
*
* @throws ReflectionException
*/
protected function _handleBaseException($exception)
{

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -83,7 +81,7 @@ function stopProfile(string $sProfileName): void
* @throws DebugBarException
* @return void
*/
function debugVar(mixed $mVar, bool $blToFile = false): void
function debugVar($mVar, bool $blToFile = false): void
{
if ($blToFile) {
$out = var_export($mVar, true);
@ -108,9 +106,10 @@ function debugVar(mixed $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) {
} catch (UnavailableException $e) {
dumpVar($mVar, $blToFile);
}
}

Bestand weergeven

@ -1,7 +1,3 @@
![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)
@ -9,7 +5,7 @@
The debug bar enables the display of relevant debug information in the shop frontend.
![screenshot](screenshot.png "Screenshot")
![screenshot](screenshot.jpg "Screenshot")
## Table of content
@ -29,14 +25,14 @@ Please enter the following section in the `composer.json` of your project:
```
"extra": {
"ajgl-symlinks": {
"php-debugbar/php-debugbar": {
"maximebf/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_2.0.patch"
"Add overridable functions for advanced profiling in Debug Bar": "https://git.d3data.de/D3Public/DebugBar/raw/branch/patches/overridablefunctions.patch"
}
}
}
@ -45,24 +41,18 @@ 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:^2.0
php composer require d3/oxid-debugbar:^1.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 never be activated in a public installation__.
__Please note that the DebugBar contains security-relevant information. It should therefore not be activated under any circumstances in a freely accessible installation.__
The DebugBar displays the following tabs:
- Messages
@ -75,10 +65,8 @@ 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
- Template variables
- Smarty
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

Bestand weergeven

@ -1,7 +1,3 @@
![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)
@ -9,7 +5,7 @@
Die Debug Bar ermöglicht die Darstellung relevanter Debuginformationen im Shopfrontend.
![screenshot](screenshot.png "Screenshot")
![screenshot](screenshot.jpg "Screenshot")
## Inhaltsverzeichnis
@ -29,14 +25,14 @@ Bitte tragen Sie den folgenden Abschnitt in die `composer.json` Ihres Projektes
```
"extra": {
"ajgl-symlinks": {
"php-debugbar/php-debugbar": {
"maximebf/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_2.0.patch"
"Add overridable functions for advanced profiling in Debug Bar": "https://git.d3data.de/D3Public/DebugBar/raw/branch/patches/overridablefunctions.patch"
}
}
}
@ -45,17 +41,11 @@ 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:^2.0
php composer require d3/oxid-debugbar:^1.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".
@ -75,10 +65,8 @@ 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
- Template Variablen
- Smarty
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

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*

Bestand weergeven

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

Bestand weergeven

@ -25,23 +25,34 @@
"GPL-3.0-or-later"
],
"require": {
"php": "^8.0",
"oxid-esales/oxideshop-ce": "7.0 - 7.2",
"php-debugbar/php-debugbar": "^2.1.6",
"php": ">=7.3",
"oxid-esales/oxideshop-ce": "6.8 - 6.13",
"maximebf/debugbar": "^1.18",
"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"
},
"autoload": {
"psr-4": {
"D3\\DebugBar\\": ""
"extra": {
"oxideshop": {
"blacklist-filter": [
"*.md",
"composer.json",
".php-cs-fixer.php",
"*.xml",
"*.neon",
"*.jpg"
],
"target-directory": "d3/debugbar"
}
},
"scripts": {
"php-cs-fixer": "./vendor/bin/php-cs-fixer fix --config=vendor/d3/oxid-debugbar/.php-cs-fixer.php"
"autoload": {
"psr-4": {
"D3\\DebugBar\\": "../../../source/modules/d3/debugbar"
}
}
}

Bestand weergeven

@ -1,10 +1,8 @@
<?php
/**
* 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.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
@ -23,13 +21,14 @@ 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' => '(D3) DebugBar',
'title' => $logo.' DebugBar',
'description' => [
'de' => '',
'en' => '',

BIN
screenshot.jpg Normal file

Binair bestand niet weergegeven.

Na

Breedte:  |  Hoogte:  |  Grootte: 71 KiB

Binair bestand niet weergegeven.

Voor

Breedte:  |  Hoogte:  |  Grootte: 49 KiB

Bestand weergeven

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