Skip to content

Commit

Permalink
Merge pull request phpmyadmin#19469 from MauricioFauth/privs-user-glo…
Browse files Browse the repository at this point in the history
…bals

Remove user info globals in Server\Privileges class
  • Loading branch information
MauricioFauth authored Dec 23, 2024
2 parents df70994 + 270a7ea commit c75d251
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
4 changes: 0 additions & 4 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8914,10 +8914,6 @@
<code><![CDATA[$GLOBALS['new_username']]]></code>
<code><![CDATA[$GLOBALS['pred_hostname']]]></code>
<code><![CDATA[$GLOBALS['pred_username']]]></code>
<code><![CDATA[$GLOBALS['ssl_cipher']]]></code>
<code><![CDATA[$GLOBALS['ssl_type']]]></code>
<code><![CDATA[$GLOBALS['x509_issuer']]]></code>
<code><![CDATA[$GLOBALS['x509_subject']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$paramDbName]]></code>
Expand Down
20 changes: 13 additions & 7 deletions src/Server/Privileges.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
*/
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,
Expand Down Expand Up @@ -954,13 +959,13 @@ public function getMessageAndSqlQueryForPrivilegesRevoke(
public function getRequireClause(): string

Check warning on line 959 in src/Server/Privileges.php

View workflow job for this annotation

GitHub Actions / Infection (8.2, ubuntu-latest)

Escaped Mutant for Mutator "PublicVisibility": --- Original +++ New @@ @@ * * @return string REQUIRE clause */ - public function getRequireClause() : string + protected function getRequireClause() : string { /** @var string|null $sslType */ $sslType = $_POST['ssl_type'] ?? $this->sslType;
{
/** @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 = [];
Expand Down Expand Up @@ -2063,9 +2068,10 @@ public function getDataForChangeOrCopyUser(string $oldUsername, string $oldHostn
);
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,
Expand Down

0 comments on commit c75d251

Please sign in to comment.