File manager - Edit - /home/opticamezl/www/newok/DataCollector.tar
Back
RequestDataCollector.php 0000644 00000003573 15173631600 0011360 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage System.Debug * * @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Plugin\System\Debug\DataCollector; use Joomla\Plugin\System\Debug\Extension\Debug; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Collects info about the request content while redacting potentially secret content * * @since 4.2.4 */ class RequestDataCollector extends \DebugBar\DataCollector\RequestDataCollector { /** * Called by the DebugBar when data needs to be collected * * @since 4.2.4 * * @return array */ public function collect() { $vars = ['_GET', '_POST', '_SESSION', '_COOKIE', '_SERVER']; $returnData = []; foreach ($vars as $var) { if (isset($GLOBALS[$var])) { $key = "$" . $var; $data = $GLOBALS[$var]; // Replace Joomla session data from session data, it will be collected by SessionCollector if ($var === '_SESSION' && !empty($data['joomla'])) { $data['joomla'] = '***redacted***'; } array_walk_recursive($data, static function (&$value, $key) { if (!preg_match(Debug::PROTECTED_COLLECTOR_KEYS, $key)) { return; } $value = '***redacted***'; }); if ($this->isHtmlVarDumperUsed()) { $returnData[$key] = $this->getVarDumper()->renderVar($data); } else { $returnData[$key] = $this->getDataFormatter()->formatVar($data); } } } return $returnData; } } UserCollector.php 0000644 00000002574 15173631600 0010054 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage System.Debug * * @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Plugin\System\Debug\DataCollector; use DebugBar\DataCollector\DataCollectorInterface; use Joomla\CMS\Factory; use Joomla\CMS\User\UserFactoryInterface; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * User collector that stores the user id of the person making the request allowing us to filter on it after storage * * @since 4.2.4 */ class UserCollector implements DataCollectorInterface { /** * Collector name. * * @var string * @since 4.2.4 */ private $name = 'juser'; /** * Called by the DebugBar when data needs to be collected * * @since 4.2.4 * * @return array Collected data */ public function collect() { $user = Factory::getApplication()->getIdentity() ?: Factory::getContainer()->get(UserFactoryInterface::class)->loadUserById(0); return ['user_id' => $user->id]; } /** * Returns the unique name of the collector * * @since 4.2.4 * * @return string */ public function getName() { return $this->name; } } ProfileCollector.php 0000644 00000020540 15173631600 0010527 0 ustar 00 <?php /** * This file is part of the DebugBar package. * * @copyright (c) 2013 Maxime Bouroumeau-Fuseau * @license For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Joomla\Plugin\System\Debug\DataCollector; use DebugBar\DebugBarException; use Joomla\CMS\Profiler\Profiler; use Joomla\Plugin\System\Debug\AbstractDataCollector; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Collects info about the request duration as well as providing * a way to log duration of any operations * * @since version */ class ProfileCollector extends AbstractDataCollector { /** * Request start time. * * @var float * @since 4.0.0 */ protected $requestStartTime; /** * Request end time. * * @var float * @since 4.0.0 */ protected $requestEndTime; /** * Started measures. * * @var array * @since 4.0.0 */ protected $startedMeasures = []; /** * Measures. * * @var array * @since 4.0.0 */ protected $measures = []; /** * Constructor. * * @param Registry $params Parameters. * * @since 4.0.0 */ public function __construct(Registry $params) { if (isset($_SERVER['REQUEST_TIME_FLOAT'])) { $this->requestStartTime = $_SERVER['REQUEST_TIME_FLOAT']; } else { $this->requestStartTime = microtime(true); } parent::__construct($params); } /** * Starts a measure. * * @param string $name Internal name, used to stop the measure * @param string|null $label Public name * @param string|null $collector The source of the collector * * @return void * * @since 4.0.0 */ public function startMeasure($name, $label = null, $collector = null) { $start = microtime(true); $this->startedMeasures[$name] = [ 'label' => $label ?: $name, 'start' => $start, 'collector' => $collector, ]; } /** * Check a measure exists * * @param string $name Group name. * * @return bool * * @since 4.0.0 */ public function hasStartedMeasure($name): bool { return isset($this->startedMeasures[$name]); } /** * Stops a measure. * * @param string $name Measurement name. * @param array $params Parameters * * @return void * * @since 4.0.0 * * @throws DebugBarException */ public function stopMeasure($name, array $params = []) { $end = microtime(true); if (!$this->hasStartedMeasure($name)) { throw new DebugBarException("Failed stopping measure '$name' because it hasn't been started"); } $this->addMeasure($this->startedMeasures[$name]['label'], $this->startedMeasures[$name]['start'], $end, $params, $this->startedMeasures[$name]['collector']); unset($this->startedMeasures[$name]); } /** * Adds a measure * * @param string $label A label. * @param float $start Start of request. * @param float $end End of request. * @param array $params Parameters. * @param string|null $collector A collector. * * @return void * * @since 4.0.0 */ public function addMeasure($label, $start, $end, array $params = [], $collector = null) { $this->measures[] = [ 'label' => $label, 'start' => $start, 'relative_start' => $start - $this->requestStartTime, 'end' => $end, 'relative_end' => $end - $this->requestEndTime, 'duration' => $end - $start, 'duration_str' => $this->getDataFormatter()->formatDuration($end - $start), 'params' => $params, 'collector' => $collector, ]; } /** * Utility function to measure the execution of a Closure * * @param string $label A label. * @param \Closure $closure A closure. * @param string|null $collector A collector. * * @return void * * @since 4.0.0 */ public function measure($label, \Closure $closure, $collector = null) { $name = spl_object_hash($closure); $this->startMeasure($name, $label, $collector); $result = $closure(); $params = \is_array($result) ? $result : []; $this->stopMeasure($name, $params); } /** * Returns an array of all measures * * @return array * * @since 4.0.0 */ public function getMeasures(): array { return $this->measures; } /** * Returns the request start time * * @return float * * @since 4.0.0 */ public function getRequestStartTime(): float { return $this->requestStartTime; } /** * Returns the request end time * * @return float * * @since 4.0.0 */ public function getRequestEndTime(): float { return $this->requestEndTime; } /** * Returns the duration of a request * * @return float * * @since 4.0.0 */ public function getRequestDuration(): float { if ($this->requestEndTime !== null) { return $this->requestEndTime - $this->requestStartTime; } return microtime(true) - $this->requestStartTime; } /** * Sets request end time. * * @param float $time Request end time. * * @return $this * * @since 4.4.0 */ public function setRequestEndTime($time): self { $this->requestEndTime = $time; return $this; } /** * Called by the DebugBar when data needs to be collected * * @return array Collected data * * @since 4.0.0 */ public function collect(): array { $this->requestEndTime = $this->requestEndTime ?? microtime(true); $start = $this->requestStartTime; $marks = Profiler::getInstance('Application')->getMarks(); foreach ($marks as $mark) { $mem = $this->getDataFormatter()->formatBytes(abs($mark->memory) * 1048576); $label = $mark->label . " ($mem)"; $end = $start + $mark->time / 1000; $this->addMeasure($label, $start, $end); $start = $end; } foreach (array_keys($this->startedMeasures) as $name) { $this->stopMeasure($name); } usort( $this->measures, function ($a, $b) { if ($a['start'] === $b['start']) { return 0; } return $a['start'] < $b['start'] ? -1 : 1; } ); return [ 'start' => $this->requestStartTime, 'end' => $this->requestEndTime, 'duration' => $this->getRequestDuration(), 'duration_str' => $this->getDataFormatter()->formatDuration($this->getRequestDuration()), 'measures' => array_values($this->measures), 'rawMarks' => $marks, ]; } /** * Returns the unique name of the collector * * @return string * * @since 4.0.0 */ public function getName(): string { return 'profile'; } /** * Returns a hash where keys are control names and their values * an array of options as defined in {@see \DebugBar\JavascriptRenderer::addControl()} * * @return array * * @since 4.0.0 */ public function getWidgets(): array { return [ 'profileTime' => [ 'icon' => 'clock-o', 'tooltip' => 'Request Duration', 'map' => 'profile.duration_str', 'default' => "'0ms'", ], 'profile' => [ 'icon' => 'clock-o', 'widget' => 'PhpDebugBar.Widgets.TimelineWidget', 'map' => 'profile', 'default' => '{}', ], ]; } } LanguageFilesCollector.php 0000644 00000006030 15173631600 0011633 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage System.Debug * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Plugin\System\Debug\DataCollector; use DebugBar\DataCollector\AssetProvider; use Joomla\CMS\Factory; use Joomla\CMS\Uri\Uri; use Joomla\Plugin\System\Debug\AbstractDataCollector; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * LanguageFilesDataCollector * * @since 4.0.0 */ class LanguageFilesCollector extends AbstractDataCollector implements AssetProvider { /** * Collector name. * * @var string * @since 4.0.0 */ private $name = 'languageFiles'; /** * The count. * * @var integer * @since 4.0.0 */ private $count = 0; /** * Called by the DebugBar when data needs to be collected * * @since 4.0.0 * * @return array Collected data */ public function collect(): array { $paths = Factory::getLanguage()->getPaths(); $loaded = []; foreach ($paths as $extension => $files) { $loaded[$extension] = []; foreach ($files as $file => $status) { $loaded[$extension][$file] = $status; if ($status) { $this->count++; } } } return [ 'loaded' => $loaded, 'xdebugLink' => $this->getXdebugLinkTemplate(), 'jroot' => JPATH_ROOT, 'count' => $this->count, ]; } /** * Returns the unique name of the collector * * @since 4.0.0 * * @return string */ public function getName(): string { return $this->name; } /** * Returns a hash where keys are control names and their values * an array of options as defined in {@see \DebugBar\JavascriptRenderer::addControl()} * * @since 4.0.0 * * @return array */ public function getWidgets(): array { return [ 'loaded' => [ 'icon' => 'language', 'widget' => 'PhpDebugBar.Widgets.languageFilesWidget', 'map' => $this->name, 'default' => '[]', ], 'loaded:badge' => [ 'map' => $this->name . '.count', 'default' => 'null', ], ]; } /** * Returns an array with the following keys: * - base_path * - base_url * - css: an array of filenames * - js: an array of filenames * * @since 4.0.0 * @return array */ public function getAssets(): array { return [ 'js' => Uri::root(true) . '/media/plg_system_debug/widgets/languageFiles/widget.min.js', 'css' => Uri::root(true) . '/media/plg_system_debug/widgets/languageFiles/widget.min.css', ]; } } QueryCollector.php 0000644 00000016123 15173631600 0010236 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage System.Debug * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Plugin\System\Debug\DataCollector; use DebugBar\DataCollector\AssetProvider; use Joomla\CMS\Uri\Uri; use Joomla\Database\Monitor\DebugMonitor; use Joomla\Plugin\System\Debug\AbstractDataCollector; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * QueryDataCollector * * @since 4.0.0 */ class QueryCollector extends AbstractDataCollector implements AssetProvider { /** * Collector name. * * @var string * @since 4.0.0 */ private $name = 'queries'; /** * The query monitor. * * @var DebugMonitor * @since 4.0.0 */ private $queryMonitor; /** * Profile data. * * @var array * @since 4.0.0 */ private $profiles; /** * Explain data. * * @var array * @since 4.0.0 */ private $explains; /** * Accumulated Duration. * * @var integer * @since 4.0.0 */ private $accumulatedDuration = 0; /** * Accumulated Memory. * * @var integer * @since 4.0.0 */ private $accumulatedMemory = 0; /** * Constructor. * * @param Registry $params Parameters. * @param DebugMonitor $queryMonitor Query monitor. * @param array $profiles Profile data. * @param array $explains Explain data * * @since 4.0.0 */ public function __construct(Registry $params, DebugMonitor $queryMonitor, array $profiles, array $explains) { $this->queryMonitor = $queryMonitor; parent::__construct($params); $this->profiles = $profiles; $this->explains = $explains; } /** * Called by the DebugBar when data needs to be collected * * @since 4.0.0 * * @return array Collected data */ public function collect(): array { $statements = $this->getStatements(); return [ 'data' => [ 'statements' => $statements, 'nb_statements' => \count($statements), 'accumulated_duration_str' => $this->getDataFormatter()->formatDuration($this->accumulatedDuration), 'memory_usage_str' => $this->getDataFormatter()->formatBytes($this->accumulatedMemory), 'xdebug_link' => $this->getXdebugLinkTemplate(), 'root_path' => JPATH_ROOT, ], 'count' => \count($this->queryMonitor->getLogs()), ]; } /** * Returns the unique name of the collector * * @since 4.0.0 * * @return string */ public function getName(): string { return $this->name; } /** * Returns a hash where keys are control names and their values * an array of options as defined in {@see \DebugBar\JavascriptRenderer::addControl()} * * @since 4.0.0 * * @return array */ public function getWidgets(): array { return [ 'queries' => [ 'icon' => 'database', 'widget' => 'PhpDebugBar.Widgets.SQLQueriesWidget', 'map' => $this->name . '.data', 'default' => '[]', ], 'queries:badge' => [ 'map' => $this->name . '.count', 'default' => 'null', ], ]; } /** * Assets for the collector. * * @since 4.0.0 * * @return array */ public function getAssets(): array { return [ 'css' => Uri::root(true) . '/media/plg_system_debug/widgets/sqlqueries/widget.min.css', 'js' => Uri::root(true) . '/media/plg_system_debug/widgets/sqlqueries/widget.min.js', ]; } /** * Prepare the executed statements data. * * @since 4.0.0 * * @return array */ private function getStatements(): array { $statements = []; $logs = $this->queryMonitor->getLogs(); $boundParams = $this->queryMonitor->getBoundParams(); $timings = $this->queryMonitor->getTimings(); $memoryLogs = $this->queryMonitor->getMemoryLogs(); $stacks = $this->queryMonitor->getCallStacks(); $collectStacks = $this->params->get('query_traces'); foreach ($logs as $id => $item) { $queryTime = 0; $queryMemory = 0; if ($timings && isset($timings[$id * 2 + 1])) { // Compute the query time. $queryTime = ($timings[$id * 2 + 1] - $timings[$id * 2]); $this->accumulatedDuration += $queryTime; } if ($memoryLogs && isset($memoryLogs[$id * 2 + 1])) { // Compute the query memory usage. $queryMemory = ($memoryLogs[$id * 2 + 1] - $memoryLogs[$id * 2]); $this->accumulatedMemory += $queryMemory; } $trace = []; $callerLocation = ''; if (isset($stacks[$id])) { $cnt = 0; foreach ($stacks[$id] as $i => $stack) { $class = $stack['class'] ?? ''; $file = $stack['file'] ?? ''; $line = $stack['line'] ?? ''; $caller = $this->formatCallerInfo($stack); $location = $file && $line ? "$file:$line" : 'same'; $isCaller = 0; if (\Joomla\Database\DatabaseDriver::class === $class && false === strpos($file, 'DatabaseDriver.php')) { $callerLocation = $location; $isCaller = 1; } if ($collectStacks) { $trace[] = [\count($stacks[$id]) - $cnt, $isCaller, $caller, $file, $line]; } $cnt++; } } $explain = $this->explains[$id] ?? []; $explainColumns = []; // Extract column labels for Explain table if ($explain) { $explainColumns = array_keys(reset($explain)); } $statements[] = [ 'sql' => $item, 'params' => $boundParams[$id] ?? [], 'duration_str' => $this->getDataFormatter()->formatDuration($queryTime), 'memory_str' => $this->getDataFormatter()->formatBytes($queryMemory), 'caller' => $callerLocation, 'callstack' => $trace, 'explain' => $explain, 'explain_col' => $explainColumns, 'profile' => $this->profiles[$id] ?? [], ]; } return $statements; } } MemoryCollector.php 0000644 00000006334 15173631600 0010404 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage System.Debug * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Plugin\System\Debug\DataCollector; use Joomla\Plugin\System\Debug\AbstractDataCollector; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * Collects info about the request duration as well as providing * a way to log duration of any operations * * @since 4.4.0 */ class MemoryCollector extends AbstractDataCollector { /** * @var boolean * @since 4.4.0 */ protected $realUsage = false; /** * @var float * @since 4.4.0 */ protected $peakUsage = 0; /** * @param Registry $params Parameters. * @param float $peakUsage * @param boolean $realUsage * * @since 4.4.0 */ public function __construct(Registry $params, $peakUsage = null, $realUsage = null) { parent::__construct($params); if ($peakUsage !== null) { $this->peakUsage = $peakUsage; } if ($realUsage !== null) { $this->realUsage = $realUsage; } } /** * Returns whether total allocated memory page size is used instead of actual used memory size * by the application. See $real_usage parameter on memory_get_peak_usage for details. * * @return boolean * * @since 4.4.0 */ public function getRealUsage() { return $this->realUsage; } /** * Sets whether total allocated memory page size is used instead of actual used memory size * by the application. See $real_usage parameter on memory_get_peak_usage for details. * * @param boolean $realUsage * * @since 4.4.0 */ public function setRealUsage($realUsage) { $this->realUsage = $realUsage; } /** * Returns the peak memory usage * * @return integer * * @since 4.4.0 */ public function getPeakUsage() { return $this->peakUsage; } /** * Updates the peak memory usage value * * @since 4.4.0 */ public function updatePeakUsage() { if ($this->peakUsage === null) { $this->peakUsage = memory_get_peak_usage($this->realUsage); } } /** * @return array * * @since 4.4.0 */ public function collect() { $this->updatePeakUsage(); return [ 'peak_usage' => $this->peakUsage, 'peak_usage_str' => $this->getDataFormatter()->formatBytes($this->peakUsage, 3), ]; } /** * @return string * * @since 4.4.0 */ public function getName() { return 'memory'; } /** * @return array * * @since 4.4.0 */ public function getWidgets() { return [ 'memory' => [ 'icon' => 'cogs', 'tooltip' => 'Memory Usage', 'map' => 'memory.peak_usage_str', 'default' => "'0B'", ], ]; } } SessionCollector.php 0000644 00000005641 15173631600 0010557 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage System.Debug * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Plugin\System\Debug\DataCollector; use Joomla\CMS\Factory; use Joomla\Plugin\System\Debug\AbstractDataCollector; use Joomla\Plugin\System\Debug\Extension\Debug; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * SessionDataCollector * * @since 4.0.0 */ class SessionCollector extends AbstractDataCollector { /** * Collector name. * * @var string * @since 4.0.0 */ private $name = 'session'; /** * Collected data. * * @var array * @since 4.4.0 */ protected $sessionData; /** * Constructor. * * @param Registry $params Parameters. * @param bool $collect Collect the session data. * * @since 4.4.0 */ public function __construct($params, $collect = false) { parent::__construct($params); if ($collect) { $this->collect(); } } /** * Called by the DebugBar when data needs to be collected * * @param bool $overwrite Overwrite the previously collected session data. * * @return array Collected data * * @since 4.0.0 */ public function collect($overwrite = false) { if ($this->sessionData === null || $overwrite) { $this->sessionData = []; $data = Factory::getApplication()->getSession()->all(); // redact value of potentially secret keys array_walk_recursive($data, static function (&$value, $key) { if (!preg_match(Debug::PROTECTED_COLLECTOR_KEYS, $key)) { return; } $value = '***redacted***'; }); foreach ($data as $key => $value) { $this->sessionData[$key] = $this->getDataFormatter()->formatVar($value); } } return ['data' => $this->sessionData]; } /** * Returns the unique name of the collector * * @since 4.0.0 * * @return string */ public function getName() { return $this->name; } /** * Returns a hash where keys are control names and their values * an array of options as defined in {@see \DebugBar\JavascriptRenderer::addControl()} * * @since 4.0.0 * * @return array */ public function getWidgets() { return [ 'session' => [ 'icon' => 'key', 'widget' => 'PhpDebugBar.Widgets.VariableListWidget', 'map' => $this->name . '.data', 'default' => '[]', ], ]; } } LanguageStringsCollector.php 0000644 00000011452 15173631600 0012226 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage System.Debug * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Plugin\System\Debug\DataCollector; use DebugBar\DataCollector\AssetProvider; use Joomla\CMS\Factory; use Joomla\CMS\Language\Language; use Joomla\CMS\Uri\Uri; use Joomla\Plugin\System\Debug\AbstractDataCollector; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * LanguageStringsDataCollector * * @since 4.0.0 */ class LanguageStringsCollector extends AbstractDataCollector implements AssetProvider { /** * Collector name. * * @var string * @since 4.0.0 */ private $name = 'languageStrings'; /** * Called by the DebugBar when data needs to be collected * * @since 4.0.0 * * @return array Collected data */ public function collect(): array { return [ 'data' => $this->getData(), 'count' => $this->getCount(), ]; } /** * Returns the unique name of the collector * * @since 4.0.0 * * @return string */ public function getName(): string { return $this->name; } /** * Returns a hash where keys are control names and their values * an array of options as defined in {@see \DebugBar\JavascriptRenderer::addControl()} * * @since 4.0.0 * * @return array */ public function getWidgets(): array { return [ 'untranslated' => [ 'icon' => 'question-circle', 'widget' => 'PhpDebugBar.Widgets.languageStringsWidget', 'map' => $this->name . '.data', 'default' => '', ], 'untranslated:badge' => [ 'map' => $this->name . '.count', 'default' => 'null', ], ]; } /** * Returns an array with the following keys: * - base_path * - base_url * - css: an array of filenames * - js: an array of filenames * * @since 4.0.0 * @return array */ public function getAssets(): array { return [ 'js' => Uri::root(true) . '/media/plg_system_debug/widgets/languageStrings/widget.min.js', 'css' => Uri::root(true) . '/media/plg_system_debug/widgets/languageStrings/widget.min.css', ]; } /** * Collect data. * * @return array * * @since 4.0.0 */ private function getData(): array { $orphans = Factory::getLanguage()->getOrphans(); $data = []; foreach ($orphans as $orphan => $occurrences) { $data[$orphan] = []; foreach ($occurrences as $occurrence) { $item = []; $item['string'] = $occurrence['string'] ?? 'n/a'; $item['trace'] = []; $item['caller'] = ''; if (isset($occurrence['trace'])) { $cnt = 0; $trace = []; $callerLocation = ''; array_shift($occurrence['trace']); foreach ($occurrence['trace'] as $i => $stack) { $class = $stack['class'] ?? ''; $file = $stack['file'] ?? ''; $line = $stack['line'] ?? ''; $caller = $this->formatCallerInfo($stack); $location = $file && $line ? "$file:$line" : 'same'; $isCaller = 0; if (!$callerLocation && $class !== Language::class && !strpos($file, 'Text.php')) { $callerLocation = $location; $isCaller = 1; } $trace[] = [ \count($occurrence['trace']) - $cnt, $isCaller, $caller, $file, $line, ]; $cnt++; } $item['trace'] = $trace; $item['caller'] = $callerLocation; } $data[$orphan][] = $item; } } return [ 'orphans' => $data, 'jroot' => JPATH_ROOT, 'xdebugLink' => $this->getXdebugLinkTemplate(), ]; } /** * Get a count value. * * @return integer * * @since 4.0.0 */ private function getCount(): int { return \count(Factory::getLanguage()->getOrphans()); } } InfoCollector.php 0000644 00000012647 15173631600 0010033 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage System.Debug * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Plugin\System\Debug\DataCollector; use DebugBar\DataCollector\AssetProvider; use Joomla\CMS\Application\AdministratorApplication; use Joomla\CMS\Application\SiteApplication; use Joomla\CMS\Factory; use Joomla\CMS\Uri\Uri; use Joomla\CMS\User\User; use Joomla\Plugin\System\Debug\AbstractDataCollector; use Joomla\Registry\Registry; use Psr\Http\Message\ResponseInterface; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * InfoDataCollector * * @since 4.0.0 */ class InfoCollector extends AbstractDataCollector implements AssetProvider { /** * Collector name. * * @var string * @since 4.0.0 */ private $name = 'info'; /** * Request ID. * * @var string * @since 4.0.0 */ private $requestId; /** * InfoDataCollector constructor. * * @param Registry $params Parameters * @param string $requestId Request ID * * @since 4.0.0 */ public function __construct(Registry $params, $requestId) { $this->requestId = $requestId; parent::__construct($params); } /** * Returns the unique name of the collector * * @since 4.0.0 * @return string */ public function getName(): string { return $this->name; } /** * Returns a hash where keys are control names and their values * an array of options as defined in {@see \DebugBar\JavascriptRenderer::addControl()} * * @since 4.0.0 * @return array */ public function getWidgets(): array { return [ 'info' => [ 'icon' => 'info-circle', 'title' => 'J! Info', 'widget' => 'PhpDebugBar.Widgets.InfoWidget', 'map' => $this->name, 'default' => '{}', ], ]; } /** * Returns an array with the following keys: * - base_path * - base_url * - css: an array of filenames * - js: an array of filenames * * @since 4.0.0 * @return array */ public function getAssets(): array { return [ 'js' => Uri::root(true) . '/media/plg_system_debug/widgets/info/widget.min.js', 'css' => Uri::root(true) . '/media/plg_system_debug/widgets/info/widget.min.css', ]; } /** * Called by the DebugBar when data needs to be collected * * @since 4.0.0 * * @return array Collected data */ public function collect(): array { /** @type SiteApplication|AdministratorApplication $application */ $application = Factory::getApplication(); $model = $application->bootComponent('com_admin') ->getMVCFactory()->createModel('Sysinfo', 'Administrator'); return [ 'phpVersion' => PHP_VERSION, 'joomlaVersion' => JVERSION, 'requestId' => $this->requestId, 'identity' => $this->getIdentityInfo($application->getIdentity()), 'response' => $this->getResponseInfo($application->getResponse()), 'template' => $this->getTemplateInfo($application->getTemplate(true)), 'database' => $this->getDatabaseInfo($model->getInfo()), ]; } /** * Get Identity info. * * @param User $identity The identity. * * @since 4.0.0 * * @return array */ private function getIdentityInfo(User $identity): array { if (!$identity->id) { return ['type' => 'guest']; } return [ 'type' => 'user', 'id' => $identity->id, 'name' => $identity->name, 'username' => $identity->username, ]; } /** * Get response info. * * @param ResponseInterface $response The response. * * @since 4.0.0 * * @return array */ private function getResponseInfo(ResponseInterface $response): array { return [ 'status_code' => $response->getStatusCode(), ]; } /** * Get template info. * * @param object $template The template. * * @since 4.0.0 * * @return array */ private function getTemplateInfo($template): array { return [ 'template' => $template->template ?? '', 'home' => $template->home ?? '', 'id' => $template->id ?? '', ]; } /** * Get database info. * * @param array $info General information. * * @since 4.0.0 * * @return array */ private function getDatabaseInfo(array $info): array { return [ 'dbserver' => $info['dbserver'] ?? '', 'dbversion' => $info['dbversion'] ?? '', 'dbcollation' => $info['dbcollation'] ?? '', 'dbconnectioncollation' => $info['dbconnectioncollation'] ?? '', 'dbconnectionencryption' => $info['dbconnectionencryption'] ?? '', 'dbconnencryptsupported' => $info['dbconnencryptsupported'] ?? '', ]; } } LanguageErrorsCollector.php 0000644 00000006617 15173631600 0012060 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage System.Debug * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Plugin\System\Debug\DataCollector; use DebugBar\DataCollector\AssetProvider; use Joomla\CMS\Factory; use Joomla\CMS\Uri\Uri; use Joomla\Plugin\System\Debug\AbstractDataCollector; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; // phpcs:enable PSR1.Files.SideEffects /** * LanguageErrorsDataCollector * * @since 4.0.0 */ class LanguageErrorsCollector extends AbstractDataCollector implements AssetProvider { /** * Collector name. * * @var string * @since 4.0.0 */ private $name = 'languageErrors'; /** * The count. * * @var integer * @since 4.0.0 */ private $count = 0; /** * Called by the DebugBar when data needs to be collected * * @since 4.0.0 * * @return array Collected data */ public function collect(): array { return [ 'data' => [ 'files' => $this->getData(), 'jroot' => JPATH_ROOT, 'xdebugLink' => $this->getXdebugLinkTemplate(), ], 'count' => $this->getCount(), ]; } /** * Returns the unique name of the collector * * @since 4.0.0 * * @return string */ public function getName(): string { return $this->name; } /** * Returns a hash where keys are control names and their values * an array of options as defined in {@see \DebugBar\JavascriptRenderer::addControl()} * * @since 4.0.0 * * @return array */ public function getWidgets(): array { return [ 'errors' => [ 'icon' => 'warning', 'widget' => 'PhpDebugBar.Widgets.languageErrorsWidget', 'map' => $this->name . '.data', 'default' => '', ], 'errors:badge' => [ 'map' => $this->name . '.count', 'default' => 'null', ], ]; } /** * Returns an array with the following keys: * - base_path * - base_url * - css: an array of filenames * - js: an array of filenames * * @since 4.0.0 * @return array */ public function getAssets() { return [ 'js' => Uri::root(true) . '/media/plg_system_debug/widgets/languageErrors/widget.min.js', 'css' => Uri::root(true) . '/media/plg_system_debug/widgets/languageErrors/widget.min.css', ]; } /** * Collect data. * * @return array * * @since 4.0.0 */ private function getData(): array { $errorFiles = Factory::getLanguage()->getErrorFiles(); $errors = []; if (\count($errorFiles)) { foreach ($errorFiles as $file => $lines) { foreach ($lines as $line) { $errors[] = [$file, $line]; $this->count++; } } } return $errors; } /** * Get a count value. * * @return int * * @since 4.0.0 */ private function getCount(): int { return $this->count; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings