Skip to content

Commit 75e0042

Browse files
Merge pull request #19472 from MauricioFauth/lang-global-var-removal
Replace lang global var with Current::$lang prop
2 parents ae30a45 + 5548f8f commit 75e0042

65 files changed

Lines changed: 147 additions & 150 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎phpstan-baseline.neon‎

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ parameters:
570570
-
571571
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
572572
identifier: notEqual.notAllowed
573-
count: 3
573+
count: 2
574574
path: src/Config.php
575575

576576
-
@@ -2860,7 +2860,7 @@ parameters:
28602860
path: src/Controllers/HomeController.php
28612861

28622862
-
2863-
message: '#^Cannot access offset mixed on mixed\.$#'
2863+
message: '#^Cannot access offset string on mixed\.$#'
28642864
identifier: offsetAccess.nonOffsetAccessible
28652865
count: 1
28662866
path: src/Controllers/HomeController.php
@@ -3276,7 +3276,7 @@ parameters:
32763276
-
32773277
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
32783278
identifier: notEqual.notAllowed
3279-
count: 2
3279+
count: 1
32803280
path: src/Controllers/Preferences/ManageController.php
32813281

32823282
-
@@ -8988,12 +8988,6 @@ parameters:
89888988
count: 1
89898989
path: src/Header.php
89908990

8991-
-
8992-
message: '#^Parameter \#2 \$params of method PhpMyAdmin\\Scripts\:\:addFile\(\) expects array\<string, string\>, array\<string, mixed\> given\.$#'
8993-
identifier: argument.type
8994-
count: 1
8995-
path: src/Header.php
8996-
89978991
-
89988992
message: '#^Binary operation "\." between non\-falsy\-string and mixed results in an error\.$#'
89998993
identifier: binaryOp.invalid
@@ -9159,12 +9153,6 @@ parameters:
91599153
count: 1
91609154
path: src/Http/Middleware/DatabaseServerVersionChecking.php
91619155

9162-
-
9163-
message: '#^Cannot cast mixed to string\.$#'
9164-
identifier: cast.string
9165-
count: 1
9166-
path: src/Http/Middleware/LanguageAndThemeCookieSaving.php
9167-
91689156
-
91699157
message: '''
91709158
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
@@ -9183,12 +9171,6 @@ parameters:
91839171
count: 1
91849172
path: src/Http/Middleware/RouteParsing.php
91859173

9186-
-
9187-
message: '#^Parameter \#2 \$value of method PhpMyAdmin\\Config\:\:setCookie\(\) expects string, mixed given\.$#'
9188-
identifier: argument.type
9189-
count: 1
9190-
path: src/Http/Middleware/SetupPageRedirection.php
9191-
91929174
-
91939175
message: '''
91949176
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
@@ -9282,12 +9264,6 @@ parameters:
92829264
count: 2
92839265
path: src/Http/ServerRequest.php
92849266

9285-
-
9286-
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
9287-
identifier: equal.notAllowed
9288-
count: 1
9289-
path: src/I18n/Language.php
9290-
92919267
-
92929268
message: '#^Binary operation "\." between mixed and ''/'' results in an error\.$#'
92939269
identifier: binaryOp.invalid
@@ -9321,12 +9297,6 @@ parameters:
93219297
count: 1
93229298
path: src/I18n/LanguageManager.php
93239299

9324-
-
9325-
message: '#^Parameter \#1 \$string of function strtolower expects string, mixed given\.$#'
9326-
identifier: argument.type
9327-
count: 1
9328-
path: src/I18n/LanguageManager.php
9329-
93309300
-
93319301
message: '#^Parameter \#2 \$path of function _bindtextdomain expects string, mixed given\.$#'
93329302
identifier: argument.type
@@ -17463,7 +17433,7 @@ parameters:
1746317433
-
1746417434
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
1746517435
identifier: empty.notAllowed
17466-
count: 4
17436+
count: 2
1746717437
path: src/Url.php
1746817438

1746917439
-

‎psalm-baseline.xml‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@
15551555
<code><![CDATA[$this->config->get('TempDir')]]></code>
15561556
</MixedArgument>
15571557
<MixedArrayAccess>
1558-
<code><![CDATA[$GLOBALS['language_stats'][$GLOBALS['lang']]]]></code>
1558+
<code><![CDATA[$GLOBALS['language_stats'][Current::$lang]]]></code>
15591559
</MixedArrayAccess>
15601560
<MixedArrayOffset>
15611561
<code><![CDATA[$config->settings['Servers'][Current::$server]]]></code>
@@ -1566,9 +1566,6 @@
15661566
<PossiblyNullArgument>
15671567
<code><![CDATA[$this->config->get('TempDir')]]></code>
15681568
</PossiblyNullArgument>
1569-
<PossiblyNullArrayOffset>
1570-
<code><![CDATA[$GLOBALS['language_stats']]]></code>
1571-
</PossiblyNullArrayOffset>
15721569
<RiskyTruthyFalsyComparison>
15731570
<code><![CDATA[empty($_REQUEST['access_time'])]]></code>
15741571
<code><![CDATA[empty($config->selectedServer['verbose'])]]></code>
@@ -5552,11 +5549,6 @@
55525549
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
55535550
</DeprecatedMethod>
55545551
</file>
5555-
<file src="src/Http/Middleware/LanguageAndThemeCookieSaving.php">
5556-
<RedundantCast>
5557-
<code><![CDATA[(string) $GLOBALS['lang']]]></code>
5558-
</RedundantCast>
5559-
</file>
55605552
<file src="src/Http/Middleware/ProfilingChecking.php">
55615553
<DeprecatedMethod>
55625554
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
@@ -10137,8 +10129,6 @@
1013710129
</MixedAssignment>
1013810130
<RiskyTruthyFalsyComparison>
1013910131
<code><![CDATA[! Config::getInstance()->get('URLQueryEncryption')]]></code>
10140-
<code><![CDATA[empty($GLOBALS['lang'])]]></code>
10141-
<code><![CDATA[empty($GLOBALS['lang'])]]></code>
1014210132
<code><![CDATA[empty($config->getCookie('pma_lang'))]]></code>
1014310133
<code><![CDATA[empty($config->getCookie('pma_lang'))]]></code>
1014410134
</RiskyTruthyFalsyComparison>

‎src/Config.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,11 @@ public function loadUserPreferences(ThemeManager $themeManager, bool $isMinimumC
488488
if ($this->issetCookie('pma_lang') || isset($_POST['lang'])) {
489489
if (
490490
(! isset($configData['lang'])
491-
&& $GLOBALS['lang'] !== 'en')
491+
&& Current::$lang !== 'en')
492492
|| isset($configData['lang'])
493-
&& $GLOBALS['lang'] != $configData['lang']
493+
&& Current::$lang !== $configData['lang']
494494
) {
495-
$this->setUserValue(null, 'lang', $GLOBALS['lang'], 'en');
495+
$this->setUserValue(null, 'lang', Current::$lang, 'en');
496496
}
497497
} elseif (isset($configData['lang'])) {
498498
$languageManager = LanguageManager::getInstance();

‎src/Controllers/HomeController.php‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,6 @@ private function checkRequirements(): void
394394

395395
private function checkLanguageStats(): void
396396
{
397-
$GLOBALS['lang'] ??= null;
398-
399397
/**
400398
* Warning about incomplete translations.
401399
*
@@ -409,8 +407,8 @@ private function checkLanguageStats(): void
409407
include ROOT_PATH . 'app/language_stats.inc.php';
410408
$config = Config::getInstance();
411409
if (
412-
! isset($GLOBALS['language_stats'][$GLOBALS['lang']])
413-
|| $GLOBALS['language_stats'][$GLOBALS['lang']] >= $config->settings['TranslationWarningThreshold']
410+
! isset($GLOBALS['language_stats'][Current::$lang])
411+
|| $GLOBALS['language_stats'][Current::$lang] >= $config->settings['TranslationWarningThreshold']
414412
) {
415413
return;
416414
}

‎src/Controllers/Preferences/ManageController.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PhpMyAdmin\ConfigStorage\Relation;
1111
use PhpMyAdmin\Controllers\InvocableController;
1212
use PhpMyAdmin\Core;
13+
use PhpMyAdmin\Current;
1314
use PhpMyAdmin\File;
1415
use PhpMyAdmin\Http\Factory\ResponseFactory;
1516
use PhpMyAdmin\Http\Response;
@@ -59,7 +60,6 @@ public function __construct(
5960
public function __invoke(ServerRequest $request): Response
6061
{
6162
$GLOBALS['error'] ??= null;
62-
$GLOBALS['lang'] ??= null;
6363
$GLOBALS['query'] ??= null;
6464

6565
$route = $request->getRoute();
@@ -194,7 +194,7 @@ public function __invoke(ServerRequest $request): Response
194194
$this->themeManager->setThemeCookie();
195195
}
196196

197-
if (isset($configuration['lang']) && $configuration['lang'] != $GLOBALS['lang']) {
197+
if (isset($configuration['lang']) && $configuration['lang'] !== Current::$lang) {
198198
$redirectParams['lang'] = $configuration['lang'];
199199
}
200200

‎src/Controllers/Setup/ConfigController.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Fig\Http\Message\StatusCodeInterface;
88
use PhpMyAdmin\Config;
99
use PhpMyAdmin\Controllers\InvocableController;
10+
use PhpMyAdmin\Current;
1011
use PhpMyAdmin\Http\Factory\ResponseFactory;
1112
use PhpMyAdmin\Http\Response;
1213
use PhpMyAdmin\Http\ServerRequest;
@@ -39,7 +40,7 @@ public function __invoke(ServerRequest $request): Response
3940
$response = $this->responseFactory->createResponse(StatusCodeInterface::STATUS_NOT_FOUND);
4041

4142
return $response->write($this->template->render('error/generic', [
42-
'lang' => $GLOBALS['lang'] ?? 'en',
43+
'lang' => Current::$lang,
4344
'error_message' => __('Configuration already exists, setup is disabled!'),
4445
]));
4546
}

‎src/Controllers/Setup/FormController.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PhpMyAdmin\Config;
99
use PhpMyAdmin\Config\Forms\Setup\SetupFormList;
1010
use PhpMyAdmin\Controllers\InvocableController;
11+
use PhpMyAdmin\Current;
1112
use PhpMyAdmin\Http\Factory\ResponseFactory;
1213
use PhpMyAdmin\Http\Response;
1314
use PhpMyAdmin\Http\ServerRequest;
@@ -40,7 +41,7 @@ public function __invoke(ServerRequest $request): Response
4041
$response = $this->responseFactory->createResponse(StatusCodeInterface::STATUS_NOT_FOUND);
4142

4243
return $response->write($this->template->render('error/generic', [
43-
'lang' => $GLOBALS['lang'] ?? 'en',
44+
'lang' => Current::$lang,
4445
'error_message' => __('Configuration already exists, setup is disabled!'),
4546
]));
4647
}
@@ -57,7 +58,7 @@ public function __invoke(ServerRequest $request): Response
5758
$formClass = SetupFormList::get($formSet);
5859
if ($formClass === null) {
5960
return $response->write($this->template->render('error/generic', [
60-
'lang' => $GLOBALS['lang'] ?? 'en',
61+
'lang' => Current::$lang,
6162
'error_message' => __('Incorrect form specified!'),
6263
]));
6364
}

‎src/Controllers/Setup/HomeController.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PhpMyAdmin\Config;
99
use PhpMyAdmin\Config\ServerConfigChecks;
1010
use PhpMyAdmin\Controllers\InvocableController;
11+
use PhpMyAdmin\Current;
1112
use PhpMyAdmin\Http\Factory\ResponseFactory;
1213
use PhpMyAdmin\Http\Response;
1314
use PhpMyAdmin\Http\ServerRequest;
@@ -43,7 +44,7 @@ public function __invoke(ServerRequest $request): Response
4344
$response = $this->responseFactory->createResponse(StatusCodeInterface::STATUS_NOT_FOUND);
4445

4546
return $response->write($this->template->render('error/generic', [
46-
'lang' => $GLOBALS['lang'] ?? 'en',
47+
'lang' => Current::$lang,
4748
'error_message' => __('Configuration already exists, setup is disabled!'),
4849
]));
4950
}

‎src/Controllers/Setup/ServerDestroyController.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Fig\Http\Message\StatusCodeInterface;
88
use PhpMyAdmin\Config;
99
use PhpMyAdmin\Controllers\InvocableController;
10+
use PhpMyAdmin\Current;
1011
use PhpMyAdmin\Http\Factory\ResponseFactory;
1112
use PhpMyAdmin\Http\Response;
1213
use PhpMyAdmin\Http\ServerRequest;
@@ -37,7 +38,7 @@ public function __invoke(ServerRequest $request): Response
3738
$response = $this->responseFactory->createResponse(StatusCodeInterface::STATUS_NOT_FOUND);
3839

3940
return $response->write($this->template->render('error/generic', [
40-
'lang' => $GLOBALS['lang'] ?? 'en',
41+
'lang' => Current::$lang,
4142
'error_message' => __('Configuration already exists, setup is disabled!'),
4243
]));
4344
}

‎src/Controllers/Setup/ServersController.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PhpMyAdmin\Config;
99
use PhpMyAdmin\Config\Forms\Setup\ServersForm;
1010
use PhpMyAdmin\Controllers\InvocableController;
11+
use PhpMyAdmin\Current;
1112
use PhpMyAdmin\Http\Factory\ResponseFactory;
1213
use PhpMyAdmin\Http\Response;
1314
use PhpMyAdmin\Http\ServerRequest;
@@ -40,7 +41,7 @@ public function __invoke(ServerRequest $request): Response
4041
$response = $this->responseFactory->createResponse(StatusCodeInterface::STATUS_NOT_FOUND);
4142

4243
return $response->write($this->template->render('error/generic', [
43-
'lang' => $GLOBALS['lang'] ?? 'en',
44+
'lang' => Current::$lang,
4445
'error_message' => __('Configuration already exists, setup is disabled!'),
4546
]));
4647
}

0 commit comments

Comments
 (0)