CoreFiles by mySites.guru
RequestDataCollector.php60 lines, 1,624 bytes, from Joomla_4.3.2-Stable-Full_Package.zip
Raw History Compare with 4.3.1
md5
528df2eff1863c94cced040bba169c41
sha1
c7faea3782b29b8caad3cd6f799dcfe3e6a5a868
sha256
7b4e18a72f042bc86466f06692a1e76dd6ab7cd3e74ae225e5c5a52dadefb498
<?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;

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

                array_walk_recursive($data, static function (&$value, $key) {
                    if (!preg_match(\PlgSystemDebug::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 12 releases, Joomla 4.3.0-beta1 to 4.3.2. See them all, or every version of this file.