Add dedicated methods for is_setup
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
a1e99f958d
commit
2756f27249
@ -1023,30 +1023,12 @@ parameters:
|
||||
count: 1
|
||||
path: src/Config/FormDisplay.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in &&, mixed given on the left side\.$#'
|
||||
identifier: booleanAnd.leftNotBoolean
|
||||
count: 1
|
||||
path: src/Config/FormDisplay.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in a negated boolean, int\|string\|false given\.$#'
|
||||
identifier: booleanNot.exprNotBoolean
|
||||
count: 1
|
||||
path: src/Config/FormDisplay.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in a ternary operator condition, mixed given\.$#'
|
||||
identifier: ternary.condNotBoolean
|
||||
count: 1
|
||||
path: src/Config/FormDisplay.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
|
||||
identifier: if.condNotBoolean
|
||||
count: 3
|
||||
path: src/Config/FormDisplay.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$array of function array_flip expects array\<int\|string\>, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
@ -1182,12 +1164,6 @@ parameters:
|
||||
-
|
||||
message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#'
|
||||
identifier: booleanNot.exprNotBoolean
|
||||
count: 2
|
||||
path: src/Config/FormDisplayTemplate.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in a ternary operator condition, mixed given\.$#'
|
||||
identifier: ternary.condNotBoolean
|
||||
count: 1
|
||||
path: src/Config/FormDisplayTemplate.php
|
||||
|
||||
@ -1485,12 +1461,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Config/Validator.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
|
||||
identifier: if.condNotBoolean
|
||||
count: 1
|
||||
path: src/Config/Validator.php
|
||||
|
||||
-
|
||||
message: '#^PHPDoc tag @var with type string is not subtype of native type non\-empty\-string\|null\.$#'
|
||||
identifier: varTag.nativeType
|
||||
@ -6492,12 +6462,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Core.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in an if condition, mixed given\.$#'
|
||||
identifier: if.condNotBoolean
|
||||
count: 1
|
||||
path: src/Core.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$sqlQuery of static method PhpMyAdmin\\Html\\Generator\:\:formatSql\(\) expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
@ -16464,12 +16428,6 @@ parameters:
|
||||
count: 2
|
||||
path: src/Sanitize.php
|
||||
|
||||
-
|
||||
message: '#^Method PhpMyAdmin\\Sanitize\:\:isSetup\(\) should return bool but returns mixed\.$#'
|
||||
identifier: return.type
|
||||
count: 1
|
||||
path: src/Sanitize.php
|
||||
|
||||
-
|
||||
message: '#^Method PhpMyAdmin\\Sanitize\:\:sanitizeFilename\(\) should return string but returns string\|null\.$#'
|
||||
identifier: return.type
|
||||
@ -19038,7 +18996,7 @@ parameters:
|
||||
-
|
||||
message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#'
|
||||
identifier: booleanNot.exprNotBoolean
|
||||
count: 2
|
||||
count: 1
|
||||
path: src/Url.php
|
||||
|
||||
-
|
||||
|
||||
@ -184,7 +184,6 @@
|
||||
<code><![CDATA[$this->settings]]></code>
|
||||
<code><![CDATA[$this->settings]]></code>
|
||||
<code><![CDATA[$this->settings]]></code>
|
||||
<code><![CDATA[$this->settings]]></code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$collationConnection]]></code>
|
||||
@ -422,7 +421,6 @@
|
||||
<code><![CDATA[$errorList]]></code>
|
||||
<code><![CDATA[$errorList]]></code>
|
||||
<code><![CDATA[$ip]]></code>
|
||||
<code><![CDATA[$isSetupScript]]></code>
|
||||
<code><![CDATA[$key]]></code>
|
||||
<code><![CDATA[$opts['errors']]]></code>
|
||||
<code><![CDATA[$proxies['-' . $i]]]></code>
|
||||
@ -476,22 +474,14 @@
|
||||
</PossiblyNullOperand>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[! $workPath]]></code>
|
||||
<code><![CDATA[$config->get('is_setup')]]></code>
|
||||
<code><![CDATA[$config->get('is_setup')]]></code>
|
||||
<code><![CDATA[$isSetupScript]]></code>
|
||||
<code><![CDATA[$isSetupScript]]></code>
|
||||
<code><![CDATA[$isSetupScript]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Config/FormDisplayTemplate.php">
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$isSetupScript]]></code>
|
||||
<code><![CDATA[$vName]]></code>
|
||||
<code><![CDATA[$validator]]></code>
|
||||
</MixedAssignment>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[! $isSetupScript]]></code>
|
||||
<code><![CDATA[$this->config->get('is_setup')]]></code>
|
||||
<code><![CDATA[empty($opts['errors'])]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
@ -647,7 +637,6 @@
|
||||
<code><![CDATA[$vid]]></code>
|
||||
</ReferenceReusedFromConfusingScope>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[$config->get('is_setup')]]></code>
|
||||
<code><![CDATA[empty($errorList)]]></code>
|
||||
<code><![CDATA[empty($values['Servers/1/controlpass'])]]></code>
|
||||
<code><![CDATA[empty($values['Servers/1/controluser'])]]></code>
|
||||
@ -4030,7 +4019,6 @@
|
||||
<code><![CDATA[$array]]></code>
|
||||
</PossiblyUnusedParam>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[Config::getInstance()->get('is_setup')]]></code>
|
||||
<code><![CDATA[empty($_SERVER['REMOTE_ADDR'])]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
<UnsupportedReferenceUsage>
|
||||
@ -9592,16 +9580,6 @@
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<MixedInferredReturnType>
|
||||
<code><![CDATA[bool]]></code>
|
||||
</MixedInferredReturnType>
|
||||
<MixedReturnStatement>
|
||||
<code><![CDATA[Config::getInstance()->get('is_setup')]]></code>
|
||||
<code><![CDATA[Config::getInstance()->get('is_setup')]]></code>
|
||||
</MixedReturnStatement>
|
||||
<NullableReturnStatement>
|
||||
<code><![CDATA[Config::getInstance()->get('is_setup')]]></code>
|
||||
</NullableReturnStatement>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[empty($found[3])]]></code>
|
||||
<code><![CDATA[empty($found[3])]]></code>
|
||||
@ -11015,7 +10993,6 @@
|
||||
<code><![CDATA[$values['token']]]></code>
|
||||
</MixedAssignment>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[! $config->get('is_setup')]]></code>
|
||||
<code><![CDATA[! Config::getInstance()->get('URLQueryEncryption')]]></code>
|
||||
<code><![CDATA[empty($GLOBALS['lang'])]]></code>
|
||||
<code><![CDATA[empty($GLOBALS['lang'])]]></code>
|
||||
|
||||
@ -107,6 +107,8 @@ class Config
|
||||
/** @psalm-var ServerSettingsType */
|
||||
public array $selectedServer;
|
||||
|
||||
private bool $isSetup = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = new Settings([]);
|
||||
@ -127,6 +129,16 @@ class Config
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function setSetup(bool $isSetup): void
|
||||
{
|
||||
$this->isSetup = $isSetup;
|
||||
}
|
||||
|
||||
public function isSetup(): bool
|
||||
{
|
||||
return $this->isSetup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $source source to read config from
|
||||
*
|
||||
@ -134,8 +146,6 @@ class Config
|
||||
*/
|
||||
public function loadAndCheck(string|null $source = null): void
|
||||
{
|
||||
$this->settings['is_setup'] = false;
|
||||
|
||||
// functions need to refresh in case of config file changed goes in PhpMyAdmin\Config::load()
|
||||
$this->load($source);
|
||||
|
||||
|
||||
@ -546,7 +546,7 @@ class FormDisplay
|
||||
$result = true;
|
||||
$values = [];
|
||||
$toSave = [];
|
||||
$isSetupScript = Config::getInstance()->get('is_setup');
|
||||
$isSetupScript = Config::getInstance()->isSetup();
|
||||
if ($isSetupScript) {
|
||||
$this->loadUserprefsInfo();
|
||||
}
|
||||
@ -746,7 +746,7 @@ class FormDisplay
|
||||
$this->userprefsKeys = array_flip(UserFormList::getFields());
|
||||
// read real config for user preferences display
|
||||
$config = Config::getInstance();
|
||||
$userPrefsDisallow = $config->get('is_setup')
|
||||
$userPrefsDisallow = $config->isSetup()
|
||||
? $this->configFile->get('UserprefsDisallow', [])
|
||||
: $config->settings['UserprefsDisallow'];
|
||||
$this->userprefsDisallow = array_flip($userPrefsDisallow ?? []);
|
||||
@ -808,7 +808,7 @@ class FormDisplay
|
||||
}
|
||||
|
||||
$config = Config::getInstance();
|
||||
if ($config->get('is_setup')) {
|
||||
if ($config->isSetup()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ class FormDisplayTemplate
|
||||
bool $valueIsDefault = true,
|
||||
array|null $opts = null,
|
||||
): string {
|
||||
$isSetupScript = $this->config->get('is_setup');
|
||||
$isSetupScript = $this->config->isSetup();
|
||||
$optionIsDisabled = ! $isSetupScript && isset($opts['userprefs_allow']) && ! $opts['userprefs_allow'];
|
||||
$trClass = $this->group > 0 ? 'group-field group-field-' . $this->group : '';
|
||||
if (isset($opts['setvalue']) && $opts['setvalue'] === ':group') {
|
||||
@ -104,7 +104,7 @@ class FormDisplayTemplate
|
||||
return '';
|
||||
}
|
||||
|
||||
$colspan = $this->config->get('is_setup') ? 3 : 2;
|
||||
$colspan = $this->config->isSetup() ? 3 : 2;
|
||||
|
||||
return $this->template->render('config/form_display/group_header', [
|
||||
'group' => $this->group,
|
||||
|
||||
@ -70,7 +70,7 @@ class Validator
|
||||
|
||||
self::$validators = $cf->getDbEntry('_validators', []);
|
||||
$config = Config::getInstance();
|
||||
if ($config->get('is_setup')) {
|
||||
if ($config->isSetup()) {
|
||||
return self::$validators;
|
||||
}
|
||||
|
||||
|
||||
@ -414,7 +414,7 @@ class Core
|
||||
parse_str($arr['query'] ?? '', $vars);
|
||||
$query = http_build_query(['url' => $vars['url']]);
|
||||
|
||||
if (Config::getInstance()->get('is_setup')) {
|
||||
if (Config::getInstance()->isSetup()) {
|
||||
return '../index.php?route=/url&' . $query;
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ final class SetupPageRedirection implements MiddlewareInterface
|
||||
|
||||
// Save current language in a cookie, since it was not set in Common::run().
|
||||
$this->config->setCookie('pma_lang', $GLOBALS['lang']);
|
||||
$this->config->set('is_setup', true);
|
||||
$this->config->setSetup(true);
|
||||
|
||||
// allows for redirection even after sending some data
|
||||
ob_start();
|
||||
|
||||
@ -88,7 +88,7 @@ class Sanitize
|
||||
*/
|
||||
public static function isSetup(): bool
|
||||
{
|
||||
return Config::getInstance()->get('is_setup');
|
||||
return Config::getInstance()->isSetup();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -215,7 +215,7 @@ class Url
|
||||
Current::$server > 0
|
||||
&& Current::$server !== $config->settings['ServerDefault']
|
||||
&& ! isset($params['server'])
|
||||
&& ! $config->get('is_setup')
|
||||
&& ! $config->isSetup()
|
||||
) {
|
||||
$params['server'] = Current::$server;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ class FormDisplayTemplateTest extends AbstractTestCase
|
||||
|
||||
// second case
|
||||
|
||||
$this->config->set('is_setup', true);
|
||||
$this->config->setSetup(true);
|
||||
$opts = [];
|
||||
$opts['errors'] = [];
|
||||
$opts['setvalue'] = 'setVal';
|
||||
@ -203,14 +203,14 @@ class FormDisplayTemplateTest extends AbstractTestCase
|
||||
|
||||
$this->formDisplayTemplate->group = 3;
|
||||
|
||||
$this->config->set('is_setup', true);
|
||||
$this->config->setSetup(true);
|
||||
|
||||
$result = $this->formDisplayTemplate->displayGroupHeader('headerText');
|
||||
|
||||
self::assertStringContainsString('<tr class="group-header group-header-4">', $result);
|
||||
|
||||
// without PMA_SETUP
|
||||
$this->config->set('is_setup', false);
|
||||
$this->config->setSetup(false);
|
||||
|
||||
$this->formDisplayTemplate->group = 3;
|
||||
|
||||
|
||||
@ -384,7 +384,7 @@ class FormDisplayTest extends AbstractTestCase
|
||||
self::assertTrue($opts['comment_warning']);
|
||||
|
||||
$config = Config::getInstance();
|
||||
$config->set('is_setup', false);
|
||||
$config->setSetup(false);
|
||||
|
||||
$config->settings['MaxDbList'] = 10;
|
||||
$config->settings['MaxTableList'] = 10;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user