CoreFiles by mySites.guru
RequestDataCollector.php67 lines, 1,915 bytes, from Joomla_4.4.13-Stable-Full_Package.zip
Raw History Compare with 4.4.12
md5
31d186696fe3baa1cc79c06a5e0419b8
sha1
dbf0a58528fde8785c849179a7c371a2a88d6e90
sha256
d15ebc51223e56c585d84c12d46e7e3ab97aa13d9267fe7ef54d85a88ded0c56
<?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;
    }
}

The same content is in 187 releases, Joomla 4.4.0-alpha3 to 6.2.0. See them all, or every version of this file.