Skip to content

Commit 082e8a1

Browse files
authored
Plugin Debug use dummy session (#39526)
1 parent 126fa04 commit 082e8a1

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

plugins/system/debug/src/DataCollector/RequestDataCollector.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public function collect()
3939

4040
$data = $GLOBALS[$var];
4141

42+
// Replace Joomla session data from session data, it will be collected by SessionCollector
43+
if ($var === '_SESSION' && !empty($data['joomla'])) {
44+
$data['joomla'] = '***redacted***';
45+
}
46+
4247
array_walk_recursive($data, static function (&$value, $key) {
4348
if (!preg_match(\PlgSystemDebug::PROTECTED_COLLECTOR_KEYS, $key)) {
4449
return;

plugins/system/debug/src/JoomlaHttpDriver.php

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
namespace Joomla\Plugin\System\Debug;
1212

1313
use DebugBar\HttpDriverInterface;
14-
use Joomla\Application\SessionAwareWebApplicationInterface;
1514
use Joomla\Application\WebApplicationInterface;
1615
use Joomla\CMS\Application\CMSApplicationInterface;
17-
use Joomla\CMS\Session\Session;
1816

1917
// phpcs:disable PSR1.Files.SideEffects
2018
\defined('_JEXEC') or die;
@@ -34,13 +32,6 @@ final class JoomlaHttpDriver implements HttpDriverInterface
3432
*/
3533
private $app;
3634

37-
/**
38-
* @var Session
39-
*
40-
* @since 4.1.5
41-
*/
42-
private $session;
43-
4435
/**
4536
* @var array
4637
*
@@ -58,10 +49,6 @@ final class JoomlaHttpDriver implements HttpDriverInterface
5849
public function __construct(CMSApplicationInterface $app)
5950
{
6051
$this->app = $app;
61-
62-
if ($app instanceof SessionAwareWebApplicationInterface) {
63-
$this->session = $app->getSession();
64-
}
6552
}
6653

6754
/**
@@ -89,7 +76,7 @@ public function setHeaders(array $headers)
8976
*/
9077
public function isSessionStarted()
9178
{
92-
return $this->session ? $this->session->isStarted() : true;
79+
return true;
9380
}
9481

9582
/**
@@ -102,11 +89,7 @@ public function isSessionStarted()
10289
*/
10390
public function setSessionValue($name, $value)
10491
{
105-
if ($this->session) {
106-
$this->session->set($name, $value);
107-
} else {
108-
$this->dummySession[$name] = $value;
109-
}
92+
$this->dummySession[$name] = $value;
11093
}
11194

11295
/**
@@ -120,7 +103,7 @@ public function setSessionValue($name, $value)
120103
*/
121104
public function hasSessionValue($name)
122105
{
123-
return $this->session ? $this->session->has($name) : array_key_exists($name, $this->dummySession);
106+
return array_key_exists($name, $this->dummySession);
124107
}
125108

126109
/**
@@ -134,10 +117,6 @@ public function hasSessionValue($name)
134117
*/
135118
public function getSessionValue($name)
136119
{
137-
if ($this->session) {
138-
return $this->session->get($name);
139-
}
140-
141120
return $this->dummySession[$name] ?? null;
142121
}
143122

@@ -150,10 +129,6 @@ public function getSessionValue($name)
150129
*/
151130
public function deleteSessionValue($name)
152131
{
153-
if ($this->session) {
154-
$this->session->remove($name);
155-
} else {
156-
unset($this->dummySession[$name]);
157-
}
132+
unset($this->dummySession[$name]);
158133
}
159134
}

0 commit comments

Comments
 (0)