Extract setup page bootstrap to the Common class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
39270211d9
commit
dbb9d68236
@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin;
|
||||
|
||||
use PhpMyAdmin\Config\ConfigFile;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\DatabaseName;
|
||||
use PhpMyAdmin\Dbal\TableName;
|
||||
@ -38,7 +39,9 @@ use function mb_strlen;
|
||||
use function mb_strpos;
|
||||
use function mb_strrpos;
|
||||
use function mb_substr;
|
||||
use function ob_start;
|
||||
use function register_shutdown_function;
|
||||
use function restore_error_handler;
|
||||
use function session_id;
|
||||
use function strlen;
|
||||
use function time;
|
||||
@ -219,6 +222,10 @@ final class Common
|
||||
UrlRedirector::redirect($_GET['url'] ?? '');
|
||||
}
|
||||
|
||||
if ($isSetupPage) {
|
||||
self::setupPageBootstrap($config);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -629,4 +636,34 @@ final class Common
|
||||
|
||||
return self::$request;
|
||||
}
|
||||
|
||||
private static function setupPageBootstrap(Config $config): void
|
||||
{
|
||||
// use default error handler
|
||||
restore_error_handler();
|
||||
|
||||
// Save current language in a cookie, since it was not set in Common::run().
|
||||
$config->setCookie('pma_lang', (string) $GLOBALS['lang']);
|
||||
$config->set('is_setup', true);
|
||||
|
||||
$GLOBALS['ConfigFile'] = new ConfigFile();
|
||||
$GLOBALS['ConfigFile']->setPersistKeys([
|
||||
'DefaultLang',
|
||||
'ServerDefault',
|
||||
'UploadDir',
|
||||
'SaveDir',
|
||||
'Servers/1/verbose',
|
||||
'Servers/1/host',
|
||||
'Servers/1/port',
|
||||
'Servers/1/socket',
|
||||
'Servers/1/auth_type',
|
||||
'Servers/1/user',
|
||||
'Servers/1/password',
|
||||
]);
|
||||
|
||||
$GLOBALS['dbi'] = DatabaseInterface::load();
|
||||
|
||||
// allows for redirection even after sending some data
|
||||
ob_start();
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,7 +239,8 @@
|
||||
<code>$_REQUEST['back']</code>
|
||||
<code>$_REQUEST['goto']</code>
|
||||
</PossiblyInvalidCast>
|
||||
<RedundantCast occurrences="2">
|
||||
<RedundantCast occurrences="3">
|
||||
<code>(string) $GLOBALS['lang']</code>
|
||||
<code>(string) $_POST['token']</code>
|
||||
<code>(string) $_POST['token']</code>
|
||||
</RedundantCast>
|
||||
@ -14438,11 +14439,6 @@
|
||||
<code>$serviceName</code>
|
||||
</MixedAssignment>
|
||||
</file>
|
||||
<file src="setup/index.php">
|
||||
<RedundantCast occurrences="1">
|
||||
<code>(string) $GLOBALS['lang']</code>
|
||||
</RedundantCast>
|
||||
</file>
|
||||
<file src="test/classes/AbstractNetworkTestCase.php">
|
||||
<MixedAssignment occurrences="1">
|
||||
<code>$http_response_code_param</code>
|
||||
|
||||
@ -3,12 +3,10 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Common;
|
||||
use PhpMyAdmin\Config\ConfigFile;
|
||||
use PhpMyAdmin\Controllers\Setup\MainController;
|
||||
use PhpMyAdmin\Controllers\Setup\ShowConfigController;
|
||||
use PhpMyAdmin\Controllers\Setup\ValidateController;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
if (! defined('ROOT_PATH')) {
|
||||
@ -37,35 +35,6 @@ require AUTOLOAD_FILE;
|
||||
|
||||
Common::run(true);
|
||||
|
||||
// use default error handler
|
||||
restore_error_handler();
|
||||
|
||||
// Save current language in a cookie, since it was not set in Common::run().
|
||||
$GLOBALS['config']->setCookie('pma_lang', (string) $GLOBALS['lang']);
|
||||
$GLOBALS['config']->set('is_setup', true);
|
||||
|
||||
$GLOBALS['ConfigFile'] = new ConfigFile();
|
||||
$GLOBALS['ConfigFile']->setPersistKeys(
|
||||
[
|
||||
'DefaultLang',
|
||||
'ServerDefault',
|
||||
'UploadDir',
|
||||
'SaveDir',
|
||||
'Servers/1/verbose',
|
||||
'Servers/1/host',
|
||||
'Servers/1/port',
|
||||
'Servers/1/socket',
|
||||
'Servers/1/auth_type',
|
||||
'Servers/1/user',
|
||||
'Servers/1/password',
|
||||
]
|
||||
);
|
||||
|
||||
$GLOBALS['dbi'] = DatabaseInterface::load();
|
||||
|
||||
// allows for redirection even after sending some data
|
||||
ob_start();
|
||||
|
||||
$request = Common::getRequest();
|
||||
$route = $request->getRoute();
|
||||
if ($route === '/setup' || $route === '/') {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user