Remove the from_cookie global variable

Replaces it with AuthenticationCookie::$fromCookie static property.

Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
This commit is contained in:
Maurício Meneghini Fauth 2025-01-09 18:25:35 -03:00
parent 4f4f31e7e9
commit 06c62ee3e3
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
4 changed files with 7 additions and 14 deletions

View File

@ -10896,12 +10896,6 @@ parameters:
count: 1
path: src/Plugins/Auth/AuthenticationCookie.php
-
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
identifier: if.condNotBoolean
count: 1
path: src/Plugins/Auth/AuthenticationCookie.php
-
message: '#^Only booleans are allowed in an if condition, string given\.$#'
identifier: if.condNotBoolean

View File

@ -39,7 +39,6 @@
<globals>
<var name="GLOBALS" type="array{
from_cookie: bool,
knjenc: string,
maxsize: string,
memory_limit: int,

View File

@ -60,9 +60,9 @@ use const SODIUM_CRYPTO_SECRETBOX_NONCEBYTES;
class AuthenticationCookie extends AuthenticationPlugin
{
public static string $connectionError = '';
/** The user provided server to connect to */
public static string $authServer = '';
public static bool $fromCookie = false;
/**
* Displays authentication form
@ -219,7 +219,7 @@ class AuthenticationCookie extends AuthenticationPlugin
self::$authServer = '';
$this->user = $this->password = '';
$GLOBALS['from_cookie'] = false;
self::$fromCookie = false;
$config = Config::getInstance();
if (isset($_POST['pma_username']) && $_POST['pma_username'] != '') {
@ -388,7 +388,7 @@ class AuthenticationCookie extends AuthenticationPlugin
self::$authServer = $authData['server'];
}
$GLOBALS['from_cookie'] = true;
self::$fromCookie = true;
return true;
}
@ -463,7 +463,7 @@ class AuthenticationCookie extends AuthenticationPlugin
// Set server cookies if required (once per session) and, in this case,
// force reload to ensure the client accepts cookies
if ($GLOBALS['from_cookie']) {
if (self::$fromCookie) {
return null;
}

View File

@ -515,7 +515,7 @@ class AuthenticationCookieTest extends AbstractTestCase
$this->object->readCredentials(),
);
self::assertTrue($GLOBALS['from_cookie']);
self::assertTrue(AuthenticationCookie::$fromCookie);
self::assertSame('', $this->object->password);
}
@ -567,7 +567,7 @@ class AuthenticationCookieTest extends AbstractTestCase
$this->object->password = 'testPW';
Current::$server = 2;
$config->settings['LoginCookieStore'] = 100;
$GLOBALS['from_cookie'] = true;
AuthenticationCookie::$fromCookie = true;
$config->set('is_https', false);
$this->object->storeCredentials();
@ -599,7 +599,7 @@ class AuthenticationCookieTest extends AbstractTestCase
AuthenticationCookie::$authServer = 'b 2';
$this->object->password = 'testPW';
$config->settings['LoginCookieStore'] = 100;
$GLOBALS['from_cookie'] = false;
AuthenticationCookie::$fromCookie = false;
$responseStub = new ResponseRendererStub();
(new ReflectionProperty(ResponseRenderer::class, 'instance'))->setValue(null, $responseStub);