From 270a7ea2df3c68bf650bdeba9aacc4c23b573be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Mon, 23 Dec 2024 13:47:37 -0300 Subject: [PATCH] Remove user info globals in Server\Privileges class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The only global variables used were the user TLS options. So they were replaced with private properties. Signed-off-by: MaurĂ­cio Meneghini Fauth --- psalm-baseline.xml | 4 ---- src/Server/Privileges.php | 20 +++++++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 8e57dc5c9f..1089da343d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -8914,10 +8914,6 @@ - - - - diff --git a/src/Server/Privileges.php b/src/Server/Privileges.php index 1f47977a25..6f94a08294 100644 --- a/src/Server/Privileges.php +++ b/src/Server/Privileges.php @@ -70,6 +70,11 @@ use function uksort; */ class Privileges { + private string|null $sslType = null; + private string|null $sslCipher = null; + private string|null $x509Issuer = null; + private string|null $x509Subject = null; + public function __construct( public Template $template, public DatabaseInterface $dbi, @@ -954,13 +959,13 @@ class Privileges public function getRequireClause(): string { /** @var string|null $sslType */ - $sslType = $_POST['ssl_type'] ?? $GLOBALS['ssl_type'] ?? null; + $sslType = $_POST['ssl_type'] ?? $this->sslType; /** @var string|null $sslCipher */ - $sslCipher = $_POST['ssl_cipher'] ?? $GLOBALS['ssl_cipher'] ?? null; + $sslCipher = $_POST['ssl_cipher'] ?? $this->sslCipher; /** @var string|null $x509Issuer */ - $x509Issuer = $_POST['x509_issuer'] ?? $GLOBALS['x509_issuer'] ?? null; + $x509Issuer = $_POST['x509_issuer'] ?? $this->x509Issuer; /** @var string|null $x509Subject */ - $x509Subject = $_POST['x509_subject'] ?? $GLOBALS['x509_subject'] ?? null; + $x509Subject = $_POST['x509_subject'] ?? $this->x509Subject; if ($sslType === 'SPECIFIED') { $require = []; @@ -2063,9 +2068,10 @@ class Privileges ); unset($_POST['change_copy']); } else { - foreach ($row as $key => $value) { - $GLOBALS[$key] = $value; - } + $this->sslType = $row['ssl_type']; + $this->sslCipher = $row['ssl_cipher']; + $this->x509Issuer = $row['x509_issuer']; + $this->x509Subject = $row['x509_subject']; $serverVersion = $this->dbi->getVersion(); // Recent MySQL versions have the field "Password" in mysql.user,