Merge pull request #20016 from MauricioFauth/user-preferences-refactor
Extract user preferences handling from Config class
This commit is contained in:
commit
a8ff66ab05
@ -7,6 +7,8 @@ use PhpMyAdmin\Application;
|
||||
use PhpMyAdmin\Bookmarks\BookmarkRepository;
|
||||
use PhpMyAdmin\BrowseForeigners;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\ConfigStorage\RelationCleanup;
|
||||
use PhpMyAdmin\Console\Console;
|
||||
@ -30,6 +32,7 @@ use PhpMyAdmin\FlashMessenger;
|
||||
use PhpMyAdmin\Header;
|
||||
use PhpMyAdmin\Http\Factory\ResponseFactory;
|
||||
use PhpMyAdmin\Http\Middleware;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Import\Import;
|
||||
use PhpMyAdmin\Import\SimulateDml;
|
||||
use PhpMyAdmin\InsertEdit;
|
||||
@ -60,7 +63,6 @@ use PhpMyAdmin\Tracking\TrackingChecker;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\Triggers\Triggers;
|
||||
use PhpMyAdmin\UserPassword;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PhpMyAdmin\UserPrivilegesFactory;
|
||||
use PhpMyAdmin\Utils\HttpRequest;
|
||||
use PhpMyAdmin\VersionInformation;
|
||||
@ -98,7 +100,10 @@ return [
|
||||
],
|
||||
Events::class => ['class' => Events::class, 'arguments' => [DatabaseInterface::class, Config::class]],
|
||||
Export::class => ['class' => Export::class, 'arguments' => [DatabaseInterface::class, OutputHandler::class]],
|
||||
Options::class => ['class' => Options::class, 'arguments' => [Relation::class, TemplateModel::class]],
|
||||
Options::class => [
|
||||
'class' => Options::class,
|
||||
'arguments' => [Relation::class, TemplateModel::class, UserPreferencesHandler::class],
|
||||
],
|
||||
TemplateModel::class => ['class' => TemplateModel::class, 'arguments' => [DatabaseInterface::class]],
|
||||
ExpressionLanguage::class => ['class' => ExpressionLanguage::class],
|
||||
FileListing::class => ['class' => FileListing::class],
|
||||
@ -112,6 +117,7 @@ return [
|
||||
DatabaseInterface::class,
|
||||
Relation::class,
|
||||
UserPreferences::class,
|
||||
UserPreferencesHandler::class,
|
||||
],
|
||||
],
|
||||
HttpRequest::class => ['class' => HttpRequest::class],
|
||||
@ -180,15 +186,15 @@ return [
|
||||
Middleware\ThemeInitialization::class => ['class' => Middleware\ThemeInitialization::class],
|
||||
Middleware\UrlRedirection::class => [
|
||||
'class' => Middleware\UrlRedirection::class,
|
||||
'arguments' => [Config::class, Template::class, ResponseFactory::class],
|
||||
'arguments' => [Template::class, ResponseFactory::class, UserPreferencesHandler::class],
|
||||
],
|
||||
Middleware\SetupPageRedirection::class => [
|
||||
'class' => Middleware\SetupPageRedirection::class,
|
||||
'arguments' => [Config::class, ResponseFactory::class],
|
||||
'arguments' => [Config::class, ResponseFactory::class, UserPreferencesHandler::class],
|
||||
],
|
||||
Middleware\MinimumCommonRedirection::class => [
|
||||
'class' => Middleware\MinimumCommonRedirection::class,
|
||||
'arguments' => [Config::class, ResponseFactory::class],
|
||||
'arguments' => [ResponseFactory::class, UserPreferencesHandler::class],
|
||||
],
|
||||
Middleware\LanguageAndThemeCookieSaving::class => [
|
||||
'class' => Middleware\LanguageAndThemeCookieSaving::class,
|
||||
@ -196,7 +202,7 @@ return [
|
||||
],
|
||||
Middleware\LoginCookieValiditySetting::class => [
|
||||
'class' => Middleware\LoginCookieValiditySetting::class,
|
||||
'arguments' => [Config::class],
|
||||
'arguments' => [Config::class, UserPreferencesHandler::class],
|
||||
],
|
||||
Middleware\Authentication::class => [
|
||||
'class' => Middleware\Authentication::class,
|
||||
@ -225,7 +231,7 @@ return [
|
||||
Middleware\ProfilingChecking::class => ['class' => Middleware\ProfilingChecking::class],
|
||||
Middleware\UserPreferencesLoading::class => [
|
||||
'class' => Middleware\UserPreferencesLoading::class,
|
||||
'arguments' => [Config::class],
|
||||
'arguments' => [UserPreferencesHandler::class],
|
||||
],
|
||||
Middleware\RecentTableHandling::class => [
|
||||
'class' => Middleware\RecentTableHandling::class,
|
||||
@ -331,7 +337,7 @@ return [
|
||||
],
|
||||
UserPreferences::class => [
|
||||
'class' => UserPreferences::class,
|
||||
'arguments' => [DatabaseInterface::class, Relation::class, Template::class],
|
||||
'arguments' => [DatabaseInterface::class, Relation::class, Template::class, Config::class],
|
||||
],
|
||||
UserPrivilegesFactory::class => [
|
||||
'class' => UserPrivilegesFactory::class,
|
||||
@ -351,4 +357,15 @@ return [
|
||||
'class' => History::class,
|
||||
'arguments' => [DatabaseInterface::class, Relation::class, Config::class],
|
||||
],
|
||||
UserPreferencesHandler::class => [
|
||||
'class' => UserPreferencesHandler::class,
|
||||
'arguments' => [
|
||||
Config::class,
|
||||
DatabaseInterface::class,
|
||||
UserPreferences::class,
|
||||
LanguageManager::class,
|
||||
ThemeManager::class,
|
||||
],
|
||||
],
|
||||
LanguageManager::class => ['class' => LanguageManager::class, 'factory' => [LanguageManager::class, 'getInstance']],
|
||||
];
|
||||
|
||||
@ -7,6 +7,8 @@ use PhpMyAdmin\Bookmarks\BookmarkRepository;
|
||||
use PhpMyAdmin\BrowseForeigners;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\ConfigStorage\RelationCleanup;
|
||||
use PhpMyAdmin\Controllers\BrowseForeignersController;
|
||||
@ -86,7 +88,6 @@ use PhpMyAdmin\Tracking\Tracking;
|
||||
use PhpMyAdmin\Tracking\TrackingChecker;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\UserPassword;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PhpMyAdmin\UserPrivilegesFactory;
|
||||
use PhpMyAdmin\VersionInformation;
|
||||
|
||||
@ -105,7 +106,7 @@ return [
|
||||
],
|
||||
CollationConnectionController::class => [
|
||||
'class' => CollationConnectionController::class,
|
||||
'arguments' => [ResponseRenderer::class, Config::class],
|
||||
'arguments' => [ResponseRenderer::class, UserPreferencesHandler::class],
|
||||
],
|
||||
ColumnController::class => [
|
||||
'class' => ColumnController::class,
|
||||
@ -113,7 +114,7 @@ return [
|
||||
],
|
||||
UpdateNavWidthConfigController::class => [
|
||||
'class' => UpdateNavWidthConfigController::class,
|
||||
'arguments' => [ResponseRenderer::class, Config::class],
|
||||
'arguments' => [ResponseRenderer::class, UserPreferencesHandler::class],
|
||||
],
|
||||
Console\Bookmark\AddController::class => [
|
||||
'class' => Console\Bookmark\AddController::class,
|
||||
@ -125,7 +126,7 @@ return [
|
||||
],
|
||||
Console\UpdateConfigController::class => [
|
||||
'class' => Console\UpdateConfigController::class,
|
||||
'arguments' => [ResponseRenderer::class, Config::class],
|
||||
'arguments' => [ResponseRenderer::class, UserPreferencesHandler::class],
|
||||
],
|
||||
Database\CentralColumns\PopulateColumnsController::class => [
|
||||
'class' => Database\CentralColumns\PopulateColumnsController::class,
|
||||
@ -374,6 +375,7 @@ return [
|
||||
\PhpMyAdmin\Export\Export::class,
|
||||
ResponseFactory::class,
|
||||
Config::class,
|
||||
UserPreferencesHandler::class,
|
||||
],
|
||||
],
|
||||
Export\TablesController::class => [
|
||||
@ -522,7 +524,7 @@ return [
|
||||
UserPreferences::class,
|
||||
Relation::class,
|
||||
Config::class,
|
||||
ThemeManager::class,
|
||||
UserPreferencesHandler::class,
|
||||
],
|
||||
],
|
||||
Preferences\FeaturesController::class => [
|
||||
@ -532,7 +534,7 @@ return [
|
||||
UserPreferences::class,
|
||||
Relation::class,
|
||||
Config::class,
|
||||
ThemeManager::class,
|
||||
UserPreferencesHandler::class,
|
||||
],
|
||||
],
|
||||
Preferences\ImportController::class => [
|
||||
@ -542,7 +544,7 @@ return [
|
||||
UserPreferences::class,
|
||||
Relation::class,
|
||||
Config::class,
|
||||
ThemeManager::class,
|
||||
UserPreferencesHandler::class,
|
||||
],
|
||||
],
|
||||
Preferences\MainPanelController::class => [
|
||||
@ -552,7 +554,7 @@ return [
|
||||
UserPreferences::class,
|
||||
Relation::class,
|
||||
Config::class,
|
||||
ThemeManager::class,
|
||||
UserPreferencesHandler::class,
|
||||
],
|
||||
],
|
||||
Preferences\ManageController::class => [
|
||||
@ -564,6 +566,7 @@ return [
|
||||
Config::class,
|
||||
ThemeManager::class,
|
||||
ResponseFactory::class,
|
||||
UserPreferencesHandler::class,
|
||||
],
|
||||
],
|
||||
Preferences\NavigationController::class => [
|
||||
@ -573,7 +576,7 @@ return [
|
||||
UserPreferences::class,
|
||||
Relation::class,
|
||||
Config::class,
|
||||
ThemeManager::class,
|
||||
UserPreferencesHandler::class,
|
||||
],
|
||||
],
|
||||
Preferences\SqlController::class => [
|
||||
@ -583,7 +586,7 @@ return [
|
||||
UserPreferences::class,
|
||||
Relation::class,
|
||||
Config::class,
|
||||
ThemeManager::class,
|
||||
UserPreferencesHandler::class,
|
||||
],
|
||||
],
|
||||
Preferences\TwoFactorController::class => [
|
||||
|
||||
@ -294,79 +294,10 @@ parameters:
|
||||
count: 1
|
||||
path: src/Command/TwigLintCommand.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 3
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''LoginCookieValidity'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''Server'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''ThemeDefault'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 2
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''config_mtime'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 2
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''lang'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 3
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''userprefs'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 5
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''userprefs_mtime'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 2
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''userprefs_type'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 2
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset non\-falsy\-string on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 4
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Cannot cast mixed to string\.$#'
|
||||
identifier: cast.string
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
|
||||
identifier: empty.notAllowed
|
||||
count: 2
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
@ -375,45 +306,15 @@ parameters:
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in &&, string\|null given on the right side\.$#'
|
||||
identifier: booleanAnd.rightNotBoolean
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in a negated boolean, int\<0, 2\> given\.$#'
|
||||
identifier: booleanNot.exprNotBoolean
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$code of method PhpMyAdmin\\I18n\\LanguageManager\:\:getLanguage\(\) expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \.\.\.\$replacements of function array_replace_recursive expects array, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#3 \$default of method PhpMyAdmin\\Config\:\:setCookie\(\) expects string\|null, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Config\:\:\$settings \(array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\}\) does not accept array\.$#'
|
||||
identifier: assign.propertyType
|
||||
count: 2
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Config\:\:\$settings \(array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\}\) does not accept array\<mixed\>\.$#'
|
||||
identifier: assign.propertyType
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
@ -423,12 +324,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Config\:\:\$userPreferences \(''''\|''db''\|''session''\) does not accept mixed\.$#'
|
||||
identifier: assign.propertyType
|
||||
count: 1
|
||||
path: src/Config.php
|
||||
|
||||
-
|
||||
message: '#^Binary operation "\." between ''\:'' and mixed results in an error\.$#'
|
||||
identifier: binaryOp.invalid
|
||||
@ -1002,6 +897,156 @@ parameters:
|
||||
count: 1
|
||||
path: src/Config/SpecialSchemaLinks.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''userprefs'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 2
|
||||
path: src/Config/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset non\-falsy\-string on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 2
|
||||
path: src/Config/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in a negated boolean, PhpMyAdmin\\Dbal\\ResultInterface\|false given\.$#'
|
||||
identifier: booleanNot.exprNotBoolean
|
||||
count: 1
|
||||
path: src/Config/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in an if condition, string\|false\|null given\.$#'
|
||||
identifier: if.condNotBoolean
|
||||
count: 1
|
||||
path: src/Config/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$params of static method PhpMyAdmin\\Url\:\:getCommonRaw\(\) expects array\<int\|string, bool\|int\|string\>, array\<mixed\> given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Config/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$path of static method PhpMyAdmin\\Core\:\:arrayWrite\(\) expects string, \(int\|string\) given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Config/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$str of method PhpMyAdmin\\Dbal\\DatabaseInterface\:\:quoteString\(\) expects string, string\|false given\.$#'
|
||||
identifier: argument.type
|
||||
count: 2
|
||||
path: src/Config/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''LoginCookieValidity'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''Server'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''ThemeDefault'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 2
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''config_mtime'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 2
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''lang'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 3
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''userprefs'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 5
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''userprefs_mtime'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 2
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''userprefs_type'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 2
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset non\-falsy\-string on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 4
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Cannot cast mixed to string\.$#'
|
||||
identifier: cast.string
|
||||
count: 1
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
|
||||
identifier: empty.notAllowed
|
||||
count: 1
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in &&, string\|null given on the right side\.$#'
|
||||
identifier: booleanAnd.rightNotBoolean
|
||||
count: 1
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$code of method PhpMyAdmin\\I18n\\LanguageManager\:\:getLanguage\(\) expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \.\.\.\$replacements of function array_replace_recursive expects array, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#3 \$default of method PhpMyAdmin\\Config\:\:setCookie\(\) expects string\|null, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Config\:\:\$settings \(array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\}\) does not accept array\.$#'
|
||||
identifier: assign.propertyType
|
||||
count: 1
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Config\:\:\$settings \(array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\}\) does not accept array\<mixed\>\.$#'
|
||||
identifier: assign.propertyType
|
||||
count: 1
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Config\\UserPreferencesHandler\:\:\$storageType \(''''\|''db''\|''session''\) does not accept mixed\.$#'
|
||||
identifier: assign.propertyType
|
||||
count: 1
|
||||
path: src/Config/UserPreferencesHandler.php
|
||||
|
||||
-
|
||||
message: '#^Argument of an invalid type array\<mixed, mixed\>\|object supplied for foreach, only iterables are supported\.$#'
|
||||
identifier: foreach.nonIterable
|
||||
@ -2212,7 +2257,7 @@ parameters:
|
||||
path: src/Controllers/Preferences/ManageController.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$fileName of method PhpMyAdmin\\UserPreferences\:\:redirect\(\) expects string, string\|false given\.$#'
|
||||
message: '#^Parameter \#1 \$fileName of method PhpMyAdmin\\Config\\UserPreferences\:\:redirect\(\) expects string, string\|false given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/Controllers/Preferences/ManageController.php
|
||||
@ -13350,7 +13395,7 @@ parameters:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 1
|
||||
count: 2
|
||||
path: src/TwoFactor.php
|
||||
|
||||
-
|
||||
@ -13461,57 +13506,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/UserPassword.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 1
|
||||
path: src/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''userprefs'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 2
|
||||
path: src/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset non\-falsy\-string on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 2
|
||||
path: src/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in a negated boolean, PhpMyAdmin\\Dbal\\ResultInterface\|false given\.$#'
|
||||
identifier: booleanNot.exprNotBoolean
|
||||
count: 1
|
||||
path: src/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in an if condition, string\|false\|null given\.$#'
|
||||
identifier: if.condNotBoolean
|
||||
count: 1
|
||||
path: src/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$params of static method PhpMyAdmin\\Url\:\:getCommonRaw\(\) expects array\<int\|string, bool\|int\|string\>, array\<mixed\> given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$path of static method PhpMyAdmin\\Core\:\:arrayWrite\(\) expects string, \(int\|string\) given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: src/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#1 \$str of method PhpMyAdmin\\Dbal\\DatabaseInterface\:\:quoteString\(\) expects string, string\|false given\.$#'
|
||||
identifier: argument.type
|
||||
count: 2
|
||||
path: src/UserPreferences.php
|
||||
|
||||
-
|
||||
message: '#^Only booleans are allowed in a negated boolean, PhpMyAdmin\\Dbal\\ResultInterface\|false given\.$#'
|
||||
identifier: booleanNot.exprNotBoolean
|
||||
@ -14556,7 +14550,7 @@ parameters:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 1
|
||||
count: 4
|
||||
path: tests/unit/Config/PageSettingsTest.php
|
||||
|
||||
-
|
||||
@ -14700,6 +14694,90 @@ parameters:
|
||||
count: 1
|
||||
path: tests/unit/Config/SettingsTest.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 8
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 8
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''db'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''secret'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''server_2'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''settings'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''ts'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''userprefs'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Offset ''userconfig'' does not exist on array\<mixed, mixed\>\.$#'
|
||||
identifier: offsetAccess.notFound
|
||||
count: 3
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertCount\(\) expects Countable\|iterable, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$result of method PhpMyAdmin\\Tests\\Stubs\\DbiDummy\:\:addResult\(\) expects bool\|list\<non\-empty\-list\<float\|int\|string\|null\>\>, array\{array\{non\-empty\-string\|false, 1767029179\}\} given\.$#'
|
||||
identifier: argument.type
|
||||
count: 2
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#3 \$subject of function str_replace expects array\<string\>\|string, string\|false given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Config\:\:\$settings \(array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\}\) does not accept array\{''Server/hide_db''\: ''testval123'', ''Server/port''\: ''213''\}\.$#'
|
||||
identifier: assign.propertyType
|
||||
count: 1
|
||||
path: tests/unit/Config/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
|
||||
@ -16038,7 +16116,7 @@ parameters:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 1
|
||||
count: 2
|
||||
path: tests/unit/Export/OptionsTest.php
|
||||
|
||||
-
|
||||
@ -17370,90 +17448,6 @@ parameters:
|
||||
count: 4
|
||||
path: tests/unit/UrlTest.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 5
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Dbal\\DatabaseInterface\:
|
||||
Use dependency injection instead\.$#
|
||||
'''
|
||||
identifier: staticMethod.deprecated
|
||||
count: 8
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''db'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''secret'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''server_2'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''settings'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''ts'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Cannot access offset ''userprefs'' on mixed\.$#'
|
||||
identifier: offsetAccess.nonOffsetAccessible
|
||||
count: 1
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Offset ''userconfig'' does not exist on array\<mixed, mixed\>\.$#'
|
||||
identifier: offsetAccess.notFound
|
||||
count: 3
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertCount\(\) expects Countable\|iterable, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$result of method PhpMyAdmin\\Tests\\Stubs\\DbiDummy\:\:addResult\(\) expects bool\|list\<non\-empty\-list\<float\|int\|string\|null\>\>, array\{array\{non\-empty\-string\|false, 1767029179\}\} given\.$#'
|
||||
identifier: argument.type
|
||||
count: 2
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#3 \$subject of function str_replace expects array\<string\>\|string, string\|false given\.$#'
|
||||
identifier: argument.type
|
||||
count: 1
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '#^Property PhpMyAdmin\\Config\:\:\$settings \(array\{PmaAbsoluteUri\: string, AuthLog\: string, AuthLogSuccess\: bool, PmaNoRelation_DisableWarning\: bool, SuhosinDisableWarning\: bool, LoginCookieValidityDisableWarning\: bool, ReservedWordDisableWarning\: bool, TranslationWarningThreshold\: int, \.\.\.\}\) does not accept array\{''Server/hide_db''\: ''testval123'', ''Server/port''\: ''213''\}\.$#'
|
||||
identifier: assign.propertyType
|
||||
count: 1
|
||||
path: tests/unit/UserPreferencesTest.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
|
||||
|
||||
@ -113,53 +113,14 @@
|
||||
</UnusedVariable>
|
||||
</file>
|
||||
<file src="src/Config.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<InvalidPropertyAssignmentValue>
|
||||
<code><![CDATA[$this->settings]]></code>
|
||||
<code><![CDATA[$this->settings]]></code>
|
||||
<code><![CDATA[$this->settings]]></code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$configData]]></code>
|
||||
<code><![CDATA[$configData['lang']]]></code>
|
||||
<code><![CDATA[$defaultValue]]></code>
|
||||
</MixedArgument>
|
||||
<MixedArrayAccess>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs']['LoginCookieValidity']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs_mtime']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs_type']]]></code>
|
||||
<code><![CDATA[$configData['lang']]]></code>
|
||||
</MixedArrayAccess>
|
||||
<MixedArrayAssignment>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['config_mtime']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs_mtime']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs_type']]]></code>
|
||||
</MixedArrayAssignment>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$configData]]></code>
|
||||
<code><![CDATA[$defaultValue]]></code>
|
||||
<code><![CDATA[$defaultValue]]></code>
|
||||
<code><![CDATA[$this->userPreferences]]></code>
|
||||
<code><![CDATA[$value]]></code>
|
||||
</MixedAssignment>
|
||||
<MixedPropertyTypeCoercion>
|
||||
<code><![CDATA[$this->settings]]></code>
|
||||
<code><![CDATA[array_replace_recursive($this->settings, $configData)]]></code>
|
||||
<code><![CDATA[array_replace_recursive($this->settings, $this->config->asArray())]]></code>
|
||||
</MixedPropertyTypeCoercion>
|
||||
<PossiblyInvalidArgument>
|
||||
<code><![CDATA[$defaultValue]]></code>
|
||||
</PossiblyInvalidArgument>
|
||||
<PossiblyInvalidArrayOffset>
|
||||
<code><![CDATA[$_COOKIE[$this->getCookieName($cookieName)]]]></code>
|
||||
</PossiblyInvalidArrayOffset>
|
||||
@ -167,7 +128,6 @@
|
||||
<code><![CDATA[$this->settings]]></code>
|
||||
</PropertyTypeCoercion>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[$cookieName]]></code>
|
||||
<code><![CDATA[empty($path)]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
<TypeDoesNotContainType>
|
||||
@ -432,6 +392,69 @@
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="src/Config/UserPreferences.php">
|
||||
<MixedArgumentTypeCoercion>
|
||||
<code><![CDATA[$path]]></code>
|
||||
<code><![CDATA[$urlParams]]></code>
|
||||
</MixedArgumentTypeCoercion>
|
||||
<MixedArrayTypeCoercion>
|
||||
<code><![CDATA[$excludeList[$path]]]></code>
|
||||
</MixedArrayTypeCoercion>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$configData]]></code>
|
||||
<code><![CDATA[$configData]]></code>
|
||||
<code><![CDATA[$prefs['config_data'][$path]]]></code>
|
||||
<code><![CDATA[$timestamp]]></code>
|
||||
<code><![CDATA[$value]]></code>
|
||||
</MixedAssignment>
|
||||
<PossiblyNullOperand>
|
||||
<code><![CDATA[$hash]]></code>
|
||||
</PossiblyNullOperand>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[$hasConfig]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Config/UserPreferencesHandler.php">
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$configData]]></code>
|
||||
<code><![CDATA[$configData['lang']]]></code>
|
||||
<code><![CDATA[$defaultValue]]></code>
|
||||
</MixedArgument>
|
||||
<MixedArrayAccess>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs']['LoginCookieValidity']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs_mtime']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs_type']]]></code>
|
||||
<code><![CDATA[$configData['lang']]]></code>
|
||||
</MixedArrayAccess>
|
||||
<MixedArrayAssignment>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['config_mtime']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs_mtime']]]></code>
|
||||
<code><![CDATA[$_SESSION['cache'][$cacheKey]['userprefs_type']]]></code>
|
||||
</MixedArrayAssignment>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$configData]]></code>
|
||||
<code><![CDATA[$defaultValue]]></code>
|
||||
<code><![CDATA[$defaultValue]]></code>
|
||||
<code><![CDATA[$this->storageType]]></code>
|
||||
<code><![CDATA[$value]]></code>
|
||||
</MixedAssignment>
|
||||
<MixedPropertyTypeCoercion>
|
||||
<code><![CDATA[$this->config->settings]]></code>
|
||||
<code><![CDATA[array_replace_recursive($this->config->settings, $configData)]]></code>
|
||||
</MixedPropertyTypeCoercion>
|
||||
<PossiblyInvalidArgument>
|
||||
<code><![CDATA[$defaultValue]]></code>
|
||||
</PossiblyInvalidArgument>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[$cookieName]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/Config/Validator.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
@ -8651,6 +8674,7 @@
|
||||
</file>
|
||||
<file src="src/TwoFactor.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
@ -8703,31 +8727,6 @@
|
||||
<code><![CDATA[empty($_POST['authentication_plugin'])]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/UserPreferences.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<MixedArgumentTypeCoercion>
|
||||
<code><![CDATA[$path]]></code>
|
||||
<code><![CDATA[$urlParams]]></code>
|
||||
</MixedArgumentTypeCoercion>
|
||||
<MixedArrayTypeCoercion>
|
||||
<code><![CDATA[$excludeList[$path]]]></code>
|
||||
</MixedArrayTypeCoercion>
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$configData]]></code>
|
||||
<code><![CDATA[$configData]]></code>
|
||||
<code><![CDATA[$prefs['config_data'][$path]]]></code>
|
||||
<code><![CDATA[$timestamp]]></code>
|
||||
<code><![CDATA[$value]]></code>
|
||||
</MixedAssignment>
|
||||
<PossiblyNullOperand>
|
||||
<code><![CDATA[$hash]]></code>
|
||||
</PossiblyNullOperand>
|
||||
<RiskyTruthyFalsyComparison>
|
||||
<code><![CDATA[$hasConfig]]></code>
|
||||
</RiskyTruthyFalsyComparison>
|
||||
</file>
|
||||
<file src="src/UserPrivilegesFactory.php">
|
||||
<MixedArgument>
|
||||
<code><![CDATA[SessionCache::get('col_priv')]]></code>
|
||||
@ -9190,6 +9189,9 @@
|
||||
</file>
|
||||
<file src="tests/unit/Config/PageSettingsTest.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
@ -9228,6 +9230,38 @@
|
||||
<code><![CDATA[valuesForOBGzipProvider]]></code>
|
||||
</PossiblyUnusedMethod>
|
||||
</file>
|
||||
<file src="tests/unit/Config/UserPreferencesTest.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<InvalidPropertyAssignmentValue>
|
||||
<code><![CDATA[['Server/hide_db' => 'testval123', 'Server/port' => '213']]]></code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$_SESSION['userconfig']]]></code>
|
||||
</MixedArgument>
|
||||
<MixedArrayAccess>
|
||||
<code><![CDATA[$_SESSION['userconfig']['db']]]></code>
|
||||
<code><![CDATA[$_SESSION['userconfig']['ts']]]></code>
|
||||
<code><![CDATA[$resultConfig['2fa']['settings']]]></code>
|
||||
<code><![CDATA[$resultConfig['2fa']['settings']['secret']]]></code>
|
||||
</MixedArrayAccess>
|
||||
</file>
|
||||
<file src="tests/unit/ConfigStorage/RelationTest.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
@ -10211,6 +10245,7 @@
|
||||
<file src="tests/unit/Export/OptionsTest.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="tests/unit/FileListingTest.php">
|
||||
@ -11082,35 +11117,6 @@
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
</file>
|
||||
<file src="tests/unit/UserPreferencesTest.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
|
||||
</DeprecatedMethod>
|
||||
<InvalidPropertyAssignmentValue>
|
||||
<code><![CDATA[['Server/hide_db' => 'testval123', 'Server/port' => '213']]]></code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
<MixedArgument>
|
||||
<code><![CDATA[$_SESSION['userconfig']]]></code>
|
||||
</MixedArgument>
|
||||
<MixedArrayAccess>
|
||||
<code><![CDATA[$_SESSION['userconfig']['db']]]></code>
|
||||
<code><![CDATA[$_SESSION['userconfig']['ts']]]></code>
|
||||
<code><![CDATA[$resultConfig['2fa']['settings']]]></code>
|
||||
<code><![CDATA[$resultConfig['2fa']['settings']['secret']]]></code>
|
||||
</MixedArrayAccess>
|
||||
</file>
|
||||
<file src="tests/unit/UtilTest.php">
|
||||
<ArgumentTypeCoercion>
|
||||
<code><![CDATA[$tz]]></code>
|
||||
|
||||
205
src/Config.php
205
src/Config.php
@ -6,13 +6,9 @@ namespace PhpMyAdmin;
|
||||
|
||||
use PhpMyAdmin\Config\Settings;
|
||||
use PhpMyAdmin\Config\Settings\Server;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\ConnectionType;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Exceptions\ConfigException;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Routing\Routing;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use Throwable;
|
||||
|
||||
use function __;
|
||||
@ -102,9 +98,6 @@ class Config
|
||||
|
||||
private bool $isSetup = false;
|
||||
|
||||
/** @var ''|'db'|'session' */
|
||||
public string $userPreferences = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->config = new Settings([]);
|
||||
@ -218,184 +211,6 @@ class Config
|
||||
$this->settings = array_replace_recursive($this->settings, $this->config->asArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the connection collation
|
||||
*/
|
||||
private function setConnectionCollation(): void
|
||||
{
|
||||
$collationConnection = $this->config->DefaultConnectionCollation;
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
if ($collationConnection === '' || $collationConnection === $dbi->getDefaultCollation()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dbi->setCollation($collationConnection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads user preferences and merges them with current config
|
||||
* must be called after control connection has been established
|
||||
*/
|
||||
public function loadUserPreferences(ThemeManager $themeManager, bool $isMinimumCommon = false): void
|
||||
{
|
||||
$cacheKey = 'server_' . Current::$server;
|
||||
if (Current::$server > 0 && ! $isMinimumCommon) {
|
||||
// cache user preferences, use database only when needed
|
||||
if (
|
||||
! isset($_SESSION['cache'][$cacheKey]['userprefs'])
|
||||
|| $_SESSION['cache'][$cacheKey]['config_mtime'] < $this->sourceMtime
|
||||
) {
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi), new Template());
|
||||
$prefs = $userPreferences->load();
|
||||
$_SESSION['cache'][$cacheKey]['userprefs'] = $userPreferences->apply($prefs['config_data']);
|
||||
$_SESSION['cache'][$cacheKey]['userprefs_mtime'] = $prefs['mtime'];
|
||||
$_SESSION['cache'][$cacheKey]['userprefs_type'] = $prefs['type'];
|
||||
$_SESSION['cache'][$cacheKey]['config_mtime'] = $this->sourceMtime;
|
||||
}
|
||||
} elseif (Current::$server === 0 || ! isset($_SESSION['cache'][$cacheKey]['userprefs'])) {
|
||||
$this->userPreferences = '';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$configData = $_SESSION['cache'][$cacheKey]['userprefs'];
|
||||
// type is 'db' or 'session'
|
||||
$this->userPreferences = $_SESSION['cache'][$cacheKey]['userprefs_type'];
|
||||
$this->set('user_preferences_mtime', $_SESSION['cache'][$cacheKey]['userprefs_mtime']);
|
||||
|
||||
if (isset($configData['Server']) && is_array($configData['Server'])) {
|
||||
$serverConfig = array_replace_recursive($this->selectedServer, $configData['Server']);
|
||||
$this->selectedServer = (new Server($serverConfig))->asArray();
|
||||
}
|
||||
|
||||
// load config array
|
||||
$this->settings = array_replace_recursive($this->settings, $configData);
|
||||
$this->config = new Settings($this->settings);
|
||||
|
||||
if ($isMinimumCommon) {
|
||||
return;
|
||||
}
|
||||
|
||||
// settings below start really working on next page load, but
|
||||
// changes are made only in index.php so everything is set when
|
||||
// in frames
|
||||
|
||||
// save theme
|
||||
if ($themeManager->getThemeCookie() !== '' || isset($_REQUEST['set_theme'])) {
|
||||
if (
|
||||
(! isset($configData['ThemeDefault'])
|
||||
&& $themeManager->theme->getId() !== 'original')
|
||||
|| isset($configData['ThemeDefault'])
|
||||
&& $configData['ThemeDefault'] !== $themeManager->theme->getId()
|
||||
) {
|
||||
$this->setUserValue(
|
||||
null,
|
||||
'ThemeDefault',
|
||||
$themeManager->theme->getId(),
|
||||
'original',
|
||||
);
|
||||
}
|
||||
} elseif (
|
||||
$this->config->ThemeDefault !== $themeManager->theme->getId()
|
||||
&& $themeManager->themeExists($this->config->ThemeDefault)
|
||||
) {
|
||||
// no cookie - read default from settings
|
||||
$themeManager->setActiveTheme($this->config->ThemeDefault);
|
||||
$themeManager->setThemeCookie();
|
||||
}
|
||||
|
||||
// save language
|
||||
if ($this->issetCookie('pma_lang') || isset($_POST['lang'])) {
|
||||
if (
|
||||
(! isset($configData['lang'])
|
||||
&& Current::$lang !== 'en')
|
||||
|| isset($configData['lang'])
|
||||
&& Current::$lang !== $configData['lang']
|
||||
) {
|
||||
$this->setUserValue(null, 'lang', Current::$lang, 'en');
|
||||
}
|
||||
} elseif (isset($configData['lang'])) {
|
||||
$languageManager = LanguageManager::getInstance();
|
||||
// read language from settings
|
||||
$language = $languageManager->getLanguage($configData['lang']);
|
||||
if ($language !== false) {
|
||||
$languageManager->activate($language);
|
||||
$this->setCookie('pma_lang', $language->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
// set connection collation
|
||||
$this->setConnectionCollation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets config value which is stored in user preferences (if available)
|
||||
* or in a cookie.
|
||||
*
|
||||
* If user preferences are not yet initialized, option is applied to
|
||||
* global config and added to a update queue, which is processed
|
||||
* by {@link loadUserPreferences()}
|
||||
*
|
||||
* @param string|null $cookieName can be null
|
||||
* @param string $cfgPath configuration path
|
||||
* @param mixed $newCfgValue new value
|
||||
* @param string|null $defaultValue default value
|
||||
*/
|
||||
public function setUserValue(
|
||||
string|null $cookieName,
|
||||
string $cfgPath,
|
||||
mixed $newCfgValue,
|
||||
string|null $defaultValue = null,
|
||||
): true|Message {
|
||||
$result = true;
|
||||
// use permanent user preferences if possible
|
||||
if ($this->userPreferences !== '') {
|
||||
if ($defaultValue === null) {
|
||||
$defaultValue = Core::arrayRead($cfgPath, $this->default);
|
||||
}
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi), new Template());
|
||||
$result = $userPreferences->persistOption($cfgPath, $newCfgValue, $defaultValue);
|
||||
}
|
||||
|
||||
if ($this->userPreferences !== 'db' && $cookieName) {
|
||||
// fall back to cookies
|
||||
if ($defaultValue === null) {
|
||||
$defaultValue = Core::arrayRead($cfgPath, $this->settings);
|
||||
}
|
||||
|
||||
$this->setCookie($cookieName, (string) $newCfgValue, $defaultValue);
|
||||
}
|
||||
|
||||
Core::arrayWrite($cfgPath, $this->settings, $newCfgValue);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads value stored by {@link setUserValue()}
|
||||
*
|
||||
* @param string $cookieName cookie name
|
||||
* @param mixed $cfgValue config value
|
||||
*/
|
||||
public function getUserValue(string $cookieName, mixed $cfgValue): mixed
|
||||
{
|
||||
$cookieExists = ! empty($this->getCookie($cookieName));
|
||||
if ($this->userPreferences === 'db') {
|
||||
// permanent user preferences value exists, remove cookie
|
||||
if ($cookieExists) {
|
||||
$this->removeCookie($cookieName);
|
||||
}
|
||||
} elseif ($cookieExists) {
|
||||
return $this->getCookie($cookieName);
|
||||
}
|
||||
|
||||
// return value from $cfg array
|
||||
return $cfgValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* set source
|
||||
*
|
||||
@ -887,26 +702,6 @@ class Config
|
||||
return new Server($server);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LoginCookieValidity from preferences cache.
|
||||
*
|
||||
* No generic solution for loading preferences from cache as some settings
|
||||
* need to be kept for processing in loadUserPreferences().
|
||||
*
|
||||
* @see loadUserPreferences()
|
||||
*/
|
||||
public function getLoginCookieValidityFromCache(int $server): void
|
||||
{
|
||||
$cacheKey = 'server_' . $server;
|
||||
|
||||
if (! isset($_SESSION['cache'][$cacheKey]['userprefs']['LoginCookieValidity'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$value = $_SESSION['cache'][$cacheKey]['userprefs']['LoginCookieValidity'];
|
||||
$this->set('LoginCookieValidity', $value);
|
||||
}
|
||||
|
||||
public function getSettings(): Settings
|
||||
{
|
||||
return $this->config;
|
||||
|
||||
@ -11,7 +11,6 @@ use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\Forms\Page\PageFormList;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
use function __;
|
||||
|
||||
|
||||
@ -2,15 +2,22 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin;
|
||||
namespace PhpMyAdmin\Config;
|
||||
|
||||
use PhpMyAdmin\Config\ConfigFile;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\Forms\User\UserFormList;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\ConnectionType;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Http\Response;
|
||||
use PhpMyAdmin\Identifiers\DatabaseName;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
use function array_flip;
|
||||
@ -29,16 +36,14 @@ use function urlencode;
|
||||
/**
|
||||
* Functions for displaying user preferences pages
|
||||
*/
|
||||
class UserPreferences
|
||||
readonly class UserPreferences
|
||||
{
|
||||
private readonly Config $config;
|
||||
|
||||
public function __construct(
|
||||
private readonly DatabaseInterface $dbi,
|
||||
private readonly Relation $relation,
|
||||
private readonly Template $template,
|
||||
private DatabaseInterface $dbi,
|
||||
private Relation $relation,
|
||||
private Template $template,
|
||||
private Config $config,
|
||||
) {
|
||||
$this->config = Config::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
219
src/Config/UserPreferencesHandler.php
Normal file
219
src/Config/UserPreferencesHandler.php
Normal file
@ -0,0 +1,219 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Config;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\Settings\Server;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
|
||||
use function array_replace_recursive;
|
||||
use function is_array;
|
||||
|
||||
class UserPreferencesHandler
|
||||
{
|
||||
/** @var ''|'db'|'session' */
|
||||
public string $storageType = '';
|
||||
|
||||
public function __construct(
|
||||
private readonly Config $config,
|
||||
private readonly DatabaseInterface $dbi,
|
||||
private readonly UserPreferences $userPreferences,
|
||||
private readonly LanguageManager $languageManager,
|
||||
private readonly ThemeManager $themeManager,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads user preferences and merges them with current config
|
||||
* must be called after control connection has been established
|
||||
*/
|
||||
public function loadUserPreferences(bool $isMinimumCommon = false): void
|
||||
{
|
||||
$cacheKey = 'server_' . Current::$server;
|
||||
if (Current::$server > 0 && ! $isMinimumCommon) {
|
||||
// cache user preferences, use database only when needed
|
||||
if (
|
||||
! isset($_SESSION['cache'][$cacheKey]['userprefs'])
|
||||
|| $_SESSION['cache'][$cacheKey]['config_mtime'] < $this->config->sourceMtime
|
||||
) {
|
||||
$prefs = $this->userPreferences->load();
|
||||
$_SESSION['cache'][$cacheKey]['userprefs'] = $this->userPreferences->apply($prefs['config_data']);
|
||||
$_SESSION['cache'][$cacheKey]['userprefs_mtime'] = $prefs['mtime'];
|
||||
$_SESSION['cache'][$cacheKey]['userprefs_type'] = $prefs['type'];
|
||||
$_SESSION['cache'][$cacheKey]['config_mtime'] = $this->config->sourceMtime;
|
||||
}
|
||||
} elseif (Current::$server === 0 || ! isset($_SESSION['cache'][$cacheKey]['userprefs'])) {
|
||||
$this->storageType = '';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$configData = $_SESSION['cache'][$cacheKey]['userprefs'];
|
||||
// type is 'db' or 'session'
|
||||
$this->storageType = $_SESSION['cache'][$cacheKey]['userprefs_type'];
|
||||
$this->config->set('user_preferences_mtime', $_SESSION['cache'][$cacheKey]['userprefs_mtime']);
|
||||
|
||||
if (isset($configData['Server']) && is_array($configData['Server'])) {
|
||||
$serverConfig = array_replace_recursive($this->config->selectedServer, $configData['Server']);
|
||||
$this->config->selectedServer = (new Server($serverConfig))->asArray();
|
||||
}
|
||||
|
||||
// load config array
|
||||
$this->config->settings = array_replace_recursive($this->config->settings, $configData);
|
||||
$this->config->config = new Settings($this->config->settings);
|
||||
|
||||
if ($isMinimumCommon) {
|
||||
return;
|
||||
}
|
||||
|
||||
// settings below start really working on next page load, but
|
||||
// changes are made only in index.php so everything is set when
|
||||
// in frames
|
||||
|
||||
// save theme
|
||||
if ($this->themeManager->getThemeCookie() !== '' || isset($_REQUEST['set_theme'])) {
|
||||
if (
|
||||
(! isset($configData['ThemeDefault'])
|
||||
&& $this->themeManager->theme->getId() !== 'original')
|
||||
|| isset($configData['ThemeDefault'])
|
||||
&& $configData['ThemeDefault'] !== $this->themeManager->theme->getId()
|
||||
) {
|
||||
$this->setUserValue(
|
||||
null,
|
||||
'ThemeDefault',
|
||||
$this->themeManager->theme->getId(),
|
||||
'original',
|
||||
);
|
||||
}
|
||||
} elseif (
|
||||
$this->config->config->ThemeDefault !== $this->themeManager->theme->getId()
|
||||
&& $this->themeManager->themeExists($this->config->config->ThemeDefault)
|
||||
) {
|
||||
// no cookie - read default from settings
|
||||
$this->themeManager->setActiveTheme($this->config->config->ThemeDefault);
|
||||
$this->themeManager->setThemeCookie();
|
||||
}
|
||||
|
||||
// save language
|
||||
if ($this->config->issetCookie('pma_lang') || isset($_POST['lang'])) {
|
||||
if (
|
||||
(! isset($configData['lang'])
|
||||
&& Current::$lang !== 'en')
|
||||
|| isset($configData['lang'])
|
||||
&& Current::$lang !== $configData['lang']
|
||||
) {
|
||||
$this->setUserValue(null, 'lang', Current::$lang, 'en');
|
||||
}
|
||||
} elseif (isset($configData['lang'])) {
|
||||
// read language from settings
|
||||
$language = $this->languageManager->getLanguage($configData['lang']);
|
||||
if ($language !== false) {
|
||||
$this->languageManager->activate($language);
|
||||
$this->config->setCookie('pma_lang', $language->getCode());
|
||||
}
|
||||
}
|
||||
|
||||
// set connection collation
|
||||
$this->setConnectionCollation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LoginCookieValidity from preferences cache.
|
||||
*
|
||||
* No generic solution for loading preferences from cache as some settings
|
||||
* need to be kept for processing in {@link loadUserPreferences()}.
|
||||
*/
|
||||
public function getLoginCookieValidityFromCache(int $server): void
|
||||
{
|
||||
$cacheKey = 'server_' . $server;
|
||||
|
||||
if (! isset($_SESSION['cache'][$cacheKey]['userprefs']['LoginCookieValidity'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$value = $_SESSION['cache'][$cacheKey]['userprefs']['LoginCookieValidity'];
|
||||
$this->config->set('LoginCookieValidity', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets config value which is stored in user preferences (if available)
|
||||
* or in a cookie.
|
||||
*
|
||||
* If user preferences are not yet initialized, option is applied to
|
||||
* global config and added to a update queue, which is processed
|
||||
* by {@link loadUserPreferences()}
|
||||
*
|
||||
* @param string|null $cookieName can be null
|
||||
* @param string $cfgPath configuration path
|
||||
* @param mixed $newCfgValue new value
|
||||
* @param string|null $defaultValue default value
|
||||
*/
|
||||
public function setUserValue(
|
||||
string|null $cookieName,
|
||||
string $cfgPath,
|
||||
mixed $newCfgValue,
|
||||
string|null $defaultValue = null,
|
||||
): true|Message {
|
||||
$result = true;
|
||||
// use permanent user preferences if possible
|
||||
if ($this->storageType !== '') {
|
||||
if ($defaultValue === null) {
|
||||
$defaultValue = Core::arrayRead($cfgPath, $this->config->default);
|
||||
}
|
||||
|
||||
$result = $this->userPreferences->persistOption($cfgPath, $newCfgValue, $defaultValue);
|
||||
}
|
||||
|
||||
if ($this->storageType !== 'db' && $cookieName) {
|
||||
// fall back to cookies
|
||||
if ($defaultValue === null) {
|
||||
$defaultValue = Core::arrayRead($cfgPath, $this->config->settings);
|
||||
}
|
||||
|
||||
$this->config->setCookie($cookieName, (string) $newCfgValue, $defaultValue);
|
||||
}
|
||||
|
||||
Core::arrayWrite($cfgPath, $this->config->settings, $newCfgValue);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads value stored by {@link setUserValue()}
|
||||
*
|
||||
* @param string $cookieName cookie name
|
||||
* @param mixed $cfgValue config value
|
||||
*/
|
||||
public function getUserValue(string $cookieName, mixed $cfgValue): mixed
|
||||
{
|
||||
$cookieExists = ! empty($this->config->getCookie($cookieName));
|
||||
if ($this->storageType === 'db') {
|
||||
// permanent user preferences value exists, remove cookie
|
||||
if ($cookieExists) {
|
||||
$this->config->removeCookie($cookieName);
|
||||
}
|
||||
} elseif ($cookieExists) {
|
||||
return $this->config->getCookie($cookieName);
|
||||
}
|
||||
|
||||
// return value from $cfg array
|
||||
return $cfgValue;
|
||||
}
|
||||
|
||||
private function setConnectionCollation(): void
|
||||
{
|
||||
$collationConnection = $this->config->config->DefaultConnectionCollation;
|
||||
if ($collationConnection === '' || $collationConnection === $this->dbi->getDefaultCollation()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dbi->setCollation($collationConnection);
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Controllers;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\Http\Response;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
@ -12,15 +12,17 @@ use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Url;
|
||||
|
||||
#[Route('/collation-connection', ['POST'])]
|
||||
final class CollationConnectionController implements InvocableController
|
||||
final readonly class CollationConnectionController implements InvocableController
|
||||
{
|
||||
public function __construct(private readonly ResponseRenderer $response, private readonly Config $config)
|
||||
{
|
||||
public function __construct(
|
||||
private ResponseRenderer $response,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(ServerRequest $request): Response
|
||||
{
|
||||
$this->config->setUserValue(
|
||||
$this->userPreferencesHandler->setUserValue(
|
||||
null,
|
||||
'DefaultConnectionCollation',
|
||||
$request->getParsedBodyParam('collation_connection'),
|
||||
|
||||
@ -6,7 +6,7 @@ namespace PhpMyAdmin\Controllers\Console;
|
||||
|
||||
use Fig\Http\Message\StatusCodeInterface;
|
||||
use InvalidArgumentException;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\Controllers\InvocableController;
|
||||
use PhpMyAdmin\Http\Response;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
@ -18,11 +18,11 @@ use function in_array;
|
||||
use function is_numeric;
|
||||
|
||||
#[Route('/console/update-config', ['POST'])]
|
||||
final class UpdateConfigController implements InvocableController
|
||||
final readonly class UpdateConfigController implements InvocableController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ResponseRenderer $response,
|
||||
private readonly Config $config,
|
||||
private ResponseRenderer $response,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ final class UpdateConfigController implements InvocableController
|
||||
return $this->response->response();
|
||||
}
|
||||
|
||||
$result = $this->config->setUserValue(null, 'Console/' . $key, $value);
|
||||
$result = $this->userPreferencesHandler->setUserValue(null, 'Console/' . $key, $value);
|
||||
if ($result !== true) {
|
||||
$this->response->setStatusCode(StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR);
|
||||
$this->response->setRequestStatus(false);
|
||||
|
||||
@ -8,6 +8,7 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Controllers;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Error\ErrorHandler;
|
||||
@ -18,7 +19,6 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
use function __;
|
||||
use function in_array;
|
||||
@ -131,7 +131,12 @@ final readonly class ErrorReportController implements InvocableController
|
||||
|
||||
/* Persist always send settings */
|
||||
if ($alwaysSend === 'true') {
|
||||
$userPreferences = new UserPreferences($this->dbi, new Relation($this->dbi), $this->template);
|
||||
$userPreferences = new UserPreferences(
|
||||
$this->dbi,
|
||||
new Relation($this->dbi, $this->config),
|
||||
$this->template,
|
||||
$this->config,
|
||||
);
|
||||
$userPreferences->persistOption('SendErrorReports', 'always', 'ask');
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Controllers\Export;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\Container\ContainerBuilder;
|
||||
use PhpMyAdmin\Controllers\Database\ExportController as DatabaseExportController;
|
||||
use PhpMyAdmin\Controllers\InvocableController;
|
||||
@ -48,6 +49,7 @@ final readonly class ExportController implements InvocableController
|
||||
private Export $export,
|
||||
private ResponseFactory $responseFactory,
|
||||
private Config $config,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -228,7 +230,7 @@ final readonly class ExportController implements InvocableController
|
||||
$filenameTemplate = $request->getParsedBodyParamAsString('filename_template', '');
|
||||
|
||||
if ((bool) $rememberTemplate) {
|
||||
$this->export->rememberFilename($this->config, $exportType, $filenameTemplate);
|
||||
$this->export->rememberFilename($this->userPreferencesHandler, $exportType, $filenameTemplate);
|
||||
}
|
||||
|
||||
$filename = $this->export->getFinalFilename(
|
||||
|
||||
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Controllers\Navigation;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\Controllers\InvocableController;
|
||||
use PhpMyAdmin\Http\Response;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
@ -16,10 +16,12 @@ use function __;
|
||||
use function is_numeric;
|
||||
|
||||
#[Route('/navigation/update-width', ['POST'])]
|
||||
final class UpdateNavWidthConfigController implements InvocableController
|
||||
final readonly class UpdateNavWidthConfigController implements InvocableController
|
||||
{
|
||||
public function __construct(private readonly ResponseRenderer $response, private readonly Config $config)
|
||||
{
|
||||
public function __construct(
|
||||
private ResponseRenderer $response,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(ServerRequest $request): Response
|
||||
@ -32,7 +34,7 @@ final class UpdateNavWidthConfigController implements InvocableController
|
||||
return $this->response->response();
|
||||
}
|
||||
|
||||
$result = $this->config->setUserValue(null, 'NavigationWidth', (int) $value);
|
||||
$result = $this->userPreferencesHandler->setUserValue(null, 'NavigationWidth', (int) $value);
|
||||
if ($result === true) {
|
||||
return $this->response->response();
|
||||
}
|
||||
|
||||
@ -7,6 +7,8 @@ namespace PhpMyAdmin\Controllers\Preferences;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\ConfigFile;
|
||||
use PhpMyAdmin\Config\Forms\User\ExportForm;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\InvocableController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -16,10 +18,8 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Navigation\Navigation;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\TwoFactor;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
use function ltrim;
|
||||
|
||||
@ -31,7 +31,7 @@ final readonly class ExportController implements InvocableController
|
||||
private UserPreferences $userPreferences,
|
||||
private Relation $relation,
|
||||
private Config $config,
|
||||
private ThemeManager $themeManager,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ final readonly class ExportController implements InvocableController
|
||||
$twoFactor->save();
|
||||
if ($result === true) {
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$this->userPreferencesHandler->loadUserPreferences();
|
||||
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
|
||||
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/export', null, $hash);
|
||||
|
||||
@ -7,6 +7,8 @@ namespace PhpMyAdmin\Controllers\Preferences;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\ConfigFile;
|
||||
use PhpMyAdmin\Config\Forms\User\FeaturesForm;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\InvocableController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -16,10 +18,8 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Navigation\Navigation;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\TwoFactor;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
use function ltrim;
|
||||
|
||||
@ -31,7 +31,7 @@ final readonly class FeaturesController implements InvocableController
|
||||
private UserPreferences $userPreferences,
|
||||
private Relation $relation,
|
||||
private Config $config,
|
||||
private ThemeManager $themeManager,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ final readonly class FeaturesController implements InvocableController
|
||||
$twoFactor->save();
|
||||
if ($result === true) {
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$this->userPreferencesHandler->loadUserPreferences();
|
||||
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
|
||||
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/features', null, $hash);
|
||||
|
||||
@ -7,6 +7,8 @@ namespace PhpMyAdmin\Controllers\Preferences;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\ConfigFile;
|
||||
use PhpMyAdmin\Config\Forms\User\ImportForm;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\InvocableController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -16,10 +18,8 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Navigation\Navigation;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\TwoFactor;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
use function ltrim;
|
||||
|
||||
@ -31,7 +31,7 @@ final readonly class ImportController implements InvocableController
|
||||
private UserPreferences $userPreferences,
|
||||
private Relation $relation,
|
||||
private Config $config,
|
||||
private ThemeManager $themeManager,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ final readonly class ImportController implements InvocableController
|
||||
$twoFactor->save();
|
||||
if ($result === true) {
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$this->userPreferencesHandler->loadUserPreferences();
|
||||
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
|
||||
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/import', null, $hash);
|
||||
|
||||
@ -7,6 +7,8 @@ namespace PhpMyAdmin\Controllers\Preferences;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\ConfigFile;
|
||||
use PhpMyAdmin\Config\Forms\User\MainForm;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\InvocableController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -16,10 +18,8 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Navigation\Navigation;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\TwoFactor;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
use function ltrim;
|
||||
|
||||
@ -31,7 +31,7 @@ final readonly class MainPanelController implements InvocableController
|
||||
private UserPreferences $userPreferences,
|
||||
private Relation $relation,
|
||||
private Config $config,
|
||||
private ThemeManager $themeManager,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ final readonly class MainPanelController implements InvocableController
|
||||
$twoFactor->save();
|
||||
if ($result === true) {
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$this->userPreferencesHandler->loadUserPreferences();
|
||||
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
|
||||
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/main-panel', null, $hash);
|
||||
|
||||
@ -7,6 +7,8 @@ namespace PhpMyAdmin\Controllers\Preferences;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\ConfigFile;
|
||||
use PhpMyAdmin\Config\Forms\User\UserFormList;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\InvocableController;
|
||||
use PhpMyAdmin\Core;
|
||||
@ -20,7 +22,6 @@ use PhpMyAdmin\Navigation\Navigation;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
use function __;
|
||||
@ -47,15 +48,16 @@ use const UPLOAD_ERR_OK;
|
||||
* User preferences management page.
|
||||
*/
|
||||
#[Route('/preferences/manage', ['GET', 'POST'])]
|
||||
final class ManageController implements InvocableController
|
||||
final readonly class ManageController implements InvocableController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ResponseRenderer $response,
|
||||
private readonly UserPreferences $userPreferences,
|
||||
private readonly Relation $relation,
|
||||
private readonly Config $config,
|
||||
private readonly ThemeManager $themeManager,
|
||||
private readonly ResponseFactory $responseFactory,
|
||||
private ResponseRenderer $response,
|
||||
private UserPreferences $userPreferences,
|
||||
private Relation $relation,
|
||||
private Config $config,
|
||||
private ThemeManager $themeManager,
|
||||
private ResponseFactory $responseFactory,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -217,7 +219,7 @@ final class ManageController implements InvocableController
|
||||
}
|
||||
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$this->userPreferencesHandler->loadUserPreferences();
|
||||
|
||||
return $this->userPreferences->redirect($returnUrl ?? '', $redirectParams);
|
||||
}
|
||||
|
||||
@ -7,6 +7,8 @@ namespace PhpMyAdmin\Controllers\Preferences;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\ConfigFile;
|
||||
use PhpMyAdmin\Config\Forms\User\NaviForm;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\InvocableController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -16,10 +18,8 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Navigation\Navigation;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\TwoFactor;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
use function ltrim;
|
||||
|
||||
@ -31,7 +31,7 @@ final readonly class NavigationController implements InvocableController
|
||||
private UserPreferences $userPreferences,
|
||||
private Relation $relation,
|
||||
private Config $config,
|
||||
private ThemeManager $themeManager,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ final readonly class NavigationController implements InvocableController
|
||||
$twoFactor->save();
|
||||
if ($result === true) {
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$this->userPreferencesHandler->loadUserPreferences();
|
||||
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
|
||||
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/navigation', null, $hash);
|
||||
|
||||
@ -7,6 +7,8 @@ namespace PhpMyAdmin\Controllers\Preferences;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\ConfigFile;
|
||||
use PhpMyAdmin\Config\Forms\User\SqlForm;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\InvocableController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -16,10 +18,8 @@ use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Navigation\Navigation;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\TwoFactor;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
use function ltrim;
|
||||
|
||||
@ -31,7 +31,7 @@ final readonly class SqlController implements InvocableController
|
||||
private UserPreferences $userPreferences,
|
||||
private Relation $relation,
|
||||
private Config $config,
|
||||
private ThemeManager $themeManager,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ final readonly class SqlController implements InvocableController
|
||||
$twoFactor->save();
|
||||
if ($result === true) {
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$this->userPreferencesHandler->loadUserPreferences();
|
||||
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
|
||||
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/sql', null, $hash);
|
||||
|
||||
@ -5,13 +5,13 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Controllers;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Http\Response;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Route;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
#[Route('/themes/set', ['POST'])]
|
||||
final readonly class ThemeSetController implements InvocableController
|
||||
|
||||
@ -7,7 +7,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Export;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
@ -163,18 +163,34 @@ class Export
|
||||
}
|
||||
|
||||
public function rememberFilename(
|
||||
Config $config,
|
||||
UserPreferencesHandler $userPreferencesHandler,
|
||||
ExportType $exportType,
|
||||
string $filenameTemplate,
|
||||
): void {
|
||||
if ($exportType === ExportType::Server) {
|
||||
$config->setUserValue('pma_server_filename_template', 'Export/file_template_server', $filenameTemplate);
|
||||
$userPreferencesHandler->setUserValue(
|
||||
'pma_server_filename_template',
|
||||
'Export/file_template_server',
|
||||
$filenameTemplate,
|
||||
);
|
||||
} elseif ($exportType === ExportType::Database) {
|
||||
$config->setUserValue('pma_db_filename_template', 'Export/file_template_database', $filenameTemplate);
|
||||
$userPreferencesHandler->setUserValue(
|
||||
'pma_db_filename_template',
|
||||
'Export/file_template_database',
|
||||
$filenameTemplate,
|
||||
);
|
||||
} elseif ($exportType === ExportType::Raw) {
|
||||
$config->setUserValue('pma_raw_filename_template', 'Export/file_template_raw', $filenameTemplate);
|
||||
$userPreferencesHandler->setUserValue(
|
||||
'pma_raw_filename_template',
|
||||
'Export/file_template_raw',
|
||||
$filenameTemplate,
|
||||
);
|
||||
} else {
|
||||
$config->setUserValue('pma_table_filename_template', 'Export/file_template_table', $filenameTemplate);
|
||||
$userPreferencesHandler->setUserValue(
|
||||
'pma_table_filename_template',
|
||||
'Export/file_template_table',
|
||||
$filenameTemplate,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Export;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
@ -23,10 +24,13 @@ use function is_array;
|
||||
use function is_string;
|
||||
use function urldecode;
|
||||
|
||||
final class Options
|
||||
final readonly class Options
|
||||
{
|
||||
public function __construct(private Relation $relation, private TemplateModel $templateModel)
|
||||
{
|
||||
public function __construct(
|
||||
private Relation $relation,
|
||||
private TemplateModel $templateModel,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,20 +228,20 @@ final class Options
|
||||
|
||||
$config = Config::getInstance();
|
||||
if ($exportType === ExportType::Database) {
|
||||
return (string) $config->getUserValue(
|
||||
return (string) $this->userPreferencesHandler->getUserValue(
|
||||
'pma_db_filename_template',
|
||||
$config->settings['Export']['file_template_database'],
|
||||
);
|
||||
}
|
||||
|
||||
if ($exportType === ExportType::Table) {
|
||||
return (string) $config->getUserValue(
|
||||
return (string) $this->userPreferencesHandler->getUserValue(
|
||||
'pma_table_filename_template',
|
||||
$config->settings['Export']['file_template_table'],
|
||||
);
|
||||
}
|
||||
|
||||
return (string) $config->getUserValue(
|
||||
return (string) $this->userPreferencesHandler->getUserValue(
|
||||
'pma_server_filename_template',
|
||||
$config->settings['Export']['file_template_server'],
|
||||
);
|
||||
|
||||
@ -7,6 +7,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin;
|
||||
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Console\Console;
|
||||
use PhpMyAdmin\Container\ContainerBuilder;
|
||||
@ -63,6 +65,7 @@ class Header
|
||||
private readonly DatabaseInterface $dbi,
|
||||
private readonly Relation $relation,
|
||||
private readonly UserPreferences $userPreferences,
|
||||
private readonly UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
$this->menu = new Menu(
|
||||
$this->dbi,
|
||||
@ -266,7 +269,7 @@ class Header
|
||||
|
||||
// offer to load user preferences from localStorage
|
||||
if (
|
||||
$this->config->userPreferences === 'session'
|
||||
$this->userPreferencesHandler->storageType === 'session'
|
||||
&& ! isset($_SESSION['userprefs_autoload'])
|
||||
) {
|
||||
$loadUserPreferences = $this->userPreferences->autoloadGetHeader();
|
||||
|
||||
@ -5,22 +5,23 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Http\Middleware;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\Current;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
final class LoginCookieValiditySetting implements MiddlewareInterface
|
||||
final readonly class LoginCookieValiditySetting implements MiddlewareInterface
|
||||
{
|
||||
public function __construct(private readonly Config $config)
|
||||
public function __construct(private Config $config, private UserPreferencesHandler $userPreferencesHandler)
|
||||
{
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
if ($this->config->hasSelectedServer()) {
|
||||
$this->config->getLoginCookieValidityFromCache(Current::$server);
|
||||
$this->userPreferencesHandler->getLoginCookieValidityFromCache(Current::$server);
|
||||
}
|
||||
|
||||
return $handler->handle($request);
|
||||
|
||||
@ -4,14 +4,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Http\Middleware;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\Container\ContainerBuilder;
|
||||
use PhpMyAdmin\Exceptions\ExitException;
|
||||
use PhpMyAdmin\Http\Factory\ResponseFactory;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Routing;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
@ -19,10 +18,12 @@ use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
use function assert;
|
||||
|
||||
final class MinimumCommonRedirection implements MiddlewareInterface
|
||||
final readonly class MinimumCommonRedirection implements MiddlewareInterface
|
||||
{
|
||||
public function __construct(private readonly Config $config, private readonly ResponseFactory $responseFactory)
|
||||
{
|
||||
public function __construct(
|
||||
private ResponseFactory $responseFactory,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
@ -32,8 +33,7 @@ final class MinimumCommonRedirection implements MiddlewareInterface
|
||||
}
|
||||
|
||||
$container = ContainerBuilder::getContainer();
|
||||
$themeManager = $container->get(ThemeManager::class);
|
||||
$this->config->loadUserPreferences($themeManager, true);
|
||||
$this->userPreferencesHandler->loadUserPreferences(true);
|
||||
assert($request instanceof ServerRequest);
|
||||
|
||||
try {
|
||||
|
||||
@ -5,14 +5,13 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Http\Middleware;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Container\ContainerBuilder;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Exceptions\ExitException;
|
||||
use PhpMyAdmin\Http\Factory\ResponseFactory;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Routing\Routing;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
@ -22,10 +21,13 @@ use function assert;
|
||||
use function ob_start;
|
||||
use function restore_error_handler;
|
||||
|
||||
final class SetupPageRedirection implements MiddlewareInterface
|
||||
final readonly class SetupPageRedirection implements MiddlewareInterface
|
||||
{
|
||||
public function __construct(private readonly Config $config, private readonly ResponseFactory $responseFactory)
|
||||
{
|
||||
public function __construct(
|
||||
private Config $config,
|
||||
private ResponseFactory $responseFactory,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
@ -34,9 +36,7 @@ final class SetupPageRedirection implements MiddlewareInterface
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
$container = ContainerBuilder::getContainer();
|
||||
$themeManager = $container->get(ThemeManager::class);
|
||||
$this->config->loadUserPreferences($themeManager, true);
|
||||
$this->userPreferencesHandler->loadUserPreferences(true);
|
||||
$this->setupPageBootstrap();
|
||||
assert($request instanceof ServerRequest);
|
||||
|
||||
|
||||
@ -4,24 +4,22 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Http\Middleware;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Container\ContainerBuilder;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\Http\Factory\ResponseFactory;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\UrlRedirector;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
final class UrlRedirection implements MiddlewareInterface
|
||||
final readonly class UrlRedirection implements MiddlewareInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Config $config,
|
||||
private readonly Template $template,
|
||||
private readonly ResponseFactory $responseFactory,
|
||||
private Template $template,
|
||||
private ResponseFactory $responseFactory,
|
||||
private UserPreferencesHandler $userPreferencesHandler,
|
||||
) {
|
||||
}
|
||||
|
||||
@ -31,9 +29,7 @@ final class UrlRedirection implements MiddlewareInterface
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
$container = ContainerBuilder::getContainer();
|
||||
$themeManager = $container->get(ThemeManager::class);
|
||||
$this->config->loadUserPreferences($themeManager, true);
|
||||
$this->userPreferencesHandler->loadUserPreferences(true);
|
||||
|
||||
$urlRedirector = new UrlRedirector(ResponseRenderer::getInstance(), $this->template, $this->responseFactory);
|
||||
|
||||
|
||||
@ -4,24 +4,21 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Http\Middleware;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Container\ContainerBuilder;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
final class UserPreferencesLoading implements MiddlewareInterface
|
||||
final readonly class UserPreferencesLoading implements MiddlewareInterface
|
||||
{
|
||||
public function __construct(private readonly Config $config)
|
||||
public function __construct(private UserPreferencesHandler $userPreferencesHandler)
|
||||
{
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
$themeManager = ContainerBuilder::getContainer()->get(ThemeManager::class);
|
||||
$this->config->loadUserPreferences($themeManager);
|
||||
$this->userPreferencesHandler->loadUserPreferences();
|
||||
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ namespace PhpMyAdmin\Navigation;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Container\ContainerBuilder;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -21,7 +22,6 @@ use PhpMyAdmin\Server\Select;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PhpMyAdmin\UserPrivilegesFactory;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
@ -100,9 +100,13 @@ class Navigation
|
||||
}
|
||||
|
||||
if (self::$isSettingsEnabled) {
|
||||
$pageSettings = new PageSettings(
|
||||
new UserPreferences($this->dbi, new Relation($this->dbi), $this->template),
|
||||
$userPreferences = new UserPreferences(
|
||||
$this->dbi,
|
||||
new Relation($this->dbi, $this->config),
|
||||
$this->template,
|
||||
$this->config,
|
||||
);
|
||||
$pageSettings = new PageSettings($userPreferences);
|
||||
$pageSettings->init('Navi', 'pma_navigation_settings');
|
||||
$response->addHTML($pageSettings->getErrorHTML());
|
||||
$navigationSettings = $pageSettings->getHTML();
|
||||
|
||||
@ -9,6 +9,7 @@ namespace PhpMyAdmin;
|
||||
|
||||
use BaconQrCode\Renderer\ImageRenderer;
|
||||
use CodeLts\U2F\U2FServer\U2FServer;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
@ -56,8 +57,9 @@ class TwoFactor
|
||||
public function __construct(public string $user)
|
||||
{
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$config = Config::getInstance();
|
||||
|
||||
$this->userPreferences = new UserPreferences($dbi, new Relation($dbi), new Template());
|
||||
$this->userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config);
|
||||
$this->available = $this->getAvailableBackends();
|
||||
$this->config = $this->readConfig();
|
||||
$this->writable = $this->config['type'] === 'db';
|
||||
|
||||
@ -6,13 +6,13 @@ namespace PhpMyAdmin\Tests\Config;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PHPUnit\Framework\Attributes\BackupStaticProperties;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use ReflectionProperty;
|
||||
@ -43,8 +43,10 @@ class PageSettingsTest extends AbstractTestCase
|
||||
*/
|
||||
public function testShowGroupNonExistent(): void
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$object = new PageSettings(new UserPreferences($dbi, new Relation($dbi), new Template()));
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config);
|
||||
$object = new PageSettings($userPreferences);
|
||||
$object->init('NonExistent');
|
||||
|
||||
self::assertSame('', $object->getHTML());
|
||||
@ -58,10 +60,10 @@ class PageSettingsTest extends AbstractTestCase
|
||||
{
|
||||
(new ReflectionProperty(ResponseRenderer::class, 'instance'))->setValue(null, null);
|
||||
|
||||
$config = Config::getInstance();
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$object = new PageSettings(
|
||||
new UserPreferences($dbi, new Relation($dbi), new Template()),
|
||||
);
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config);
|
||||
$object = new PageSettings($userPreferences);
|
||||
$object->init('Browse');
|
||||
|
||||
$html = $object->getHTML();
|
||||
@ -110,10 +112,10 @@ class PageSettingsTest extends AbstractTestCase
|
||||
*/
|
||||
public function testGetNaviSettings(): void
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$pageSettings = new PageSettings(
|
||||
new UserPreferences($dbi, new Relation($dbi), new Template()),
|
||||
);
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config);
|
||||
$pageSettings = new PageSettings($userPreferences);
|
||||
$pageSettings->init('Navi', 'pma_navigation_settings');
|
||||
|
||||
$html = $pageSettings->getHTML();
|
||||
|
||||
51
tests/unit/Config/UserPreferencesHandlerTest.php
Normal file
51
tests/unit/Config/UserPreferencesHandlerTest.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\Config;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
#[CoversClass(UserPreferencesHandler::class)]
|
||||
final class UserPreferencesHandlerTest extends AbstractTestCase
|
||||
{
|
||||
public function testSetUserValue(): void
|
||||
{
|
||||
$config = new Config();
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config),
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
$userPreferencesHandler->setUserValue(null, 'lang', 'cs', 'en');
|
||||
$userPreferencesHandler->setUserValue('TEST_COOKIE_USER_VAL', '', 'cfg_val_1');
|
||||
self::assertSame('cfg_val_1', $userPreferencesHandler->getUserValue('TEST_COOKIE_USER_VAL', 'fail'));
|
||||
$userPreferencesHandler->setUserValue(null, 'NavigationWidth', 300);
|
||||
self::assertSame(300, $config->settings['NavigationWidth']);
|
||||
}
|
||||
|
||||
public function testGetUserValue(): void
|
||||
{
|
||||
$config = new Config();
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config),
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
self::assertSame('val', $userPreferencesHandler->getUserValue('test_val', 'val'));
|
||||
}
|
||||
}
|
||||
@ -2,10 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests;
|
||||
namespace PhpMyAdmin\Tests\Config;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\ConfigFile;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\ConfigStorage\RelationParameters;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -14,10 +15,10 @@ use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\ResponseRenderer;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\DummyResult;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer as ResponseRendererStub;
|
||||
use PhpMyAdmin\Url;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PHPUnit\Framework\Attributes\BackupStaticProperties;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use ReflectionProperty;
|
||||
@ -50,7 +51,7 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
$config->settings = ['Server/hide_db' => 'testval123', 'Server/port' => '213'];
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi), new Template());
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config);
|
||||
$userPreferences->pageInit(new ConfigFile());
|
||||
|
||||
self::assertSame(
|
||||
@ -69,8 +70,9 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
|
||||
unset($_SESSION['userconfig']);
|
||||
|
||||
$config = Config::getInstance();
|
||||
$dbi1 = DatabaseInterface::getInstance();
|
||||
$userPreferences = new UserPreferences($dbi1, new Relation($dbi1), new Template());
|
||||
$userPreferences = new UserPreferences($dbi1, new Relation($dbi1, $config), new Template($config), $config);
|
||||
$result = $userPreferences->load();
|
||||
|
||||
self::assertSame(
|
||||
@ -111,7 +113,7 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
->method('quoteString')
|
||||
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
|
||||
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi), new Template());
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config);
|
||||
$result = $userPreferences->load();
|
||||
|
||||
self::assertSame(
|
||||
@ -125,14 +127,15 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
*/
|
||||
public function testSave(): void
|
||||
{
|
||||
Config::getInstance()->selectedServer['DisableIS'] = true;
|
||||
$config = Config::getInstance();
|
||||
$config->selectedServer['DisableIS'] = true;
|
||||
$relationParameters = RelationParameters::fromArray([]);
|
||||
(new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters);
|
||||
|
||||
unset($_SESSION['userconfig']);
|
||||
|
||||
$dbi1 = DatabaseInterface::getInstance();
|
||||
$userPreferences = new UserPreferences($dbi1, new Relation($dbi1), new Template());
|
||||
$userPreferences = new UserPreferences($dbi1, new Relation($dbi1, $config), new Template($config), $config);
|
||||
$result = $userPreferences->save([1]);
|
||||
|
||||
self::assertTrue($result);
|
||||
@ -192,7 +195,7 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
->method('quoteString')
|
||||
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
|
||||
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi1), new Template());
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi1, $config), new Template($config), $config);
|
||||
$result = $userPreferences->save([1]);
|
||||
|
||||
self::assertTrue($result);
|
||||
@ -226,7 +229,7 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
->method('quoteString')
|
||||
->willReturnCallback(static fn (string $string): string => "'" . $string . "'");
|
||||
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi1), new Template());
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi1, $config), new Template($config), $config);
|
||||
$result = $userPreferences->save([1]);
|
||||
|
||||
self::assertInstanceOf(Message::class, $result);
|
||||
@ -270,7 +273,7 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
$relationParameters = $relation->getRelationParameters();
|
||||
self::assertNotNull($relationParameters->userPreferencesFeature);
|
||||
|
||||
$userPreferences = new UserPreferences($dbi, $relation, new Template());
|
||||
$userPreferences = new UserPreferences($dbi, $relation, new Template($config), $config);
|
||||
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
$dummyDbi->addResult(
|
||||
@ -379,7 +382,7 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
$config->settings['UserprefsDisallow'] = ['test' => 'val', 'foo' => 'bar'];
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi), new Template());
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config);
|
||||
$result = $userPreferences->apply(
|
||||
[
|
||||
'DBG/sql' => true,
|
||||
@ -401,10 +404,11 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
*/
|
||||
public function testApplyDevel(): void
|
||||
{
|
||||
Config::getInstance()->set('UserprefsDeveloperTab', true);
|
||||
$config = Config::getInstance();
|
||||
$config->set('UserprefsDeveloperTab', true);
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi), new Template());
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config);
|
||||
$result = $userPreferences->apply(
|
||||
['DBG/sql' => true],
|
||||
);
|
||||
@ -429,8 +433,9 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
|
||||
(new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters);
|
||||
|
||||
$config = Config::getInstance();
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi), new Template());
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config);
|
||||
self::assertTrue(
|
||||
$userPreferences->persistOption('Server/hide_db', 'val', 'val'),
|
||||
);
|
||||
@ -454,10 +459,11 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
Current::$database = 'db';
|
||||
Current::$table = 'table';
|
||||
|
||||
Config::getInstance()->set('PmaAbsoluteUri', '');
|
||||
$config = Config::getInstance();
|
||||
$config->set('PmaAbsoluteUri', '');
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi), new Template());
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config);
|
||||
$response = $userPreferences->redirect(
|
||||
'file.html',
|
||||
['a' => 'b'],
|
||||
@ -476,8 +482,9 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
$_SESSION['userprefs_autoload'] = false;
|
||||
$_REQUEST['prefs_autoload'] = 'hide';
|
||||
|
||||
$config = Config::getInstance();
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi), new Template());
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config);
|
||||
self::assertSame(
|
||||
'',
|
||||
$userPreferences->autoloadGetHeader(),
|
||||
@ -328,29 +328,6 @@ class ConfigTest extends AbstractTestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for setting user config value
|
||||
*/
|
||||
public function testSetUserValue(): void
|
||||
{
|
||||
$this->object->setUserValue(null, 'lang', 'cs', 'en');
|
||||
$this->object->setUserValue('TEST_COOKIE_USER_VAL', '', 'cfg_val_1');
|
||||
self::assertSame(
|
||||
$this->object->getUserValue('TEST_COOKIE_USER_VAL', 'fail'),
|
||||
'cfg_val_1',
|
||||
);
|
||||
$this->object->setUserValue(null, 'NavigationWidth', 300);
|
||||
self::assertSame($this->object->settings['NavigationWidth'], 300);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getting user config value
|
||||
*/
|
||||
public function testGetUserValue(): void
|
||||
{
|
||||
self::assertSame($this->object->getUserValue('test_val', 'val'), 'val');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for setting cookies
|
||||
*/
|
||||
|
||||
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Tests\Controllers;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\Controllers\CollationConnectionController;
|
||||
use PhpMyAdmin\Http\Factory\ResponseFactory;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
@ -26,10 +26,10 @@ class CollationConnectionControllerTest extends AbstractTestCase
|
||||
->with('index.php?route=/' . Url::getCommonRaw([], '&'));
|
||||
$response->expects(self::once())->method('response')->willReturn(ResponseFactory::create()->createResponse());
|
||||
|
||||
$config = self::createMock(Config::class);
|
||||
$config->expects(self::once())->method('setUserValue')
|
||||
$userPreferencesHandler = self::createMock(UserPreferencesHandler::class);
|
||||
$userPreferencesHandler->expects(self::once())->method('setUserValue')
|
||||
->with(null, 'DefaultConnectionCollation', 'utf8mb4_general_ci', 'utf8mb4_unicode_ci');
|
||||
|
||||
(new CollationConnectionController($response, $config))($request);
|
||||
(new CollationConnectionController($response, $userPreferencesHandler))($request);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,12 +5,18 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Controllers\Console;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\Console\UpdateConfigController;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
@ -25,11 +31,18 @@ final class UpdateConfigControllerTest extends AbstractTestCase
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/')
|
||||
->withParsedBody(['key' => $key, 'value' => $value]);
|
||||
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi = $this->createDatabaseInterface();
|
||||
$config = new Config();
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config),
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$responseRenderer->setAjax(true);
|
||||
$controller = new UpdateConfigController($responseRenderer, $config);
|
||||
$controller = new UpdateConfigController($responseRenderer, $userPreferencesHandler);
|
||||
$response = $controller($request);
|
||||
|
||||
$responseBody = (string) $response->getBody();
|
||||
@ -78,11 +91,18 @@ final class UpdateConfigControllerTest extends AbstractTestCase
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/')
|
||||
->withParsedBody(['key' => $key, 'value' => $value]);
|
||||
|
||||
DatabaseInterface::$instance = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi = $this->createDatabaseInterface();
|
||||
$config = new Config();
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config),
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$responseRenderer->setAjax(true);
|
||||
$controller = new UpdateConfigController($responseRenderer, $config);
|
||||
$controller = new UpdateConfigController($responseRenderer, $userPreferencesHandler);
|
||||
$response = $controller($request);
|
||||
|
||||
$responseBody = (string) $response->getBody();
|
||||
@ -138,11 +158,11 @@ final class UpdateConfigControllerTest extends AbstractTestCase
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/')
|
||||
->withParsedBody(['key' => 'StartHistory', 'value' => 'true']);
|
||||
|
||||
$config = self::createStub(Config::class);
|
||||
$config->method('setUserValue')->willReturn(Message::error('Could not save configuration'));
|
||||
$userPreferencesHandler = self::createStub(UserPreferencesHandler::class);
|
||||
$userPreferencesHandler->method('setUserValue')->willReturn(Message::error('Could not save configuration'));
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$responseRenderer->setAjax(true);
|
||||
$controller = new UpdateConfigController($responseRenderer, $config);
|
||||
$controller = new UpdateConfigController($responseRenderer, $userPreferencesHandler);
|
||||
$response = $controller($request);
|
||||
|
||||
$responseBody = (string) $response->getBody();
|
||||
|
||||
@ -6,6 +6,9 @@ namespace PhpMyAdmin\Tests\Controllers\Export;
|
||||
|
||||
use Fig\Http\Message\StatusCodeInterface;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Container\ContainerBuilder;
|
||||
use PhpMyAdmin\Controllers\Export\ExportController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -15,9 +18,12 @@ use PhpMyAdmin\Export\OutputHandler;
|
||||
use PhpMyAdmin\Http\Factory\ResponseFactory;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\FieldHelper;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\ZipExtension;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
@ -189,11 +195,20 @@ final class ExportControllerTest extends AbstractTestCase
|
||||
COMMIT;
|
||||
SQL;
|
||||
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config),
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
|
||||
$exportController = new ExportController(
|
||||
new ResponseRenderer(),
|
||||
new Export($dbi, new OutputHandler()),
|
||||
ResponseFactory::create(),
|
||||
$config,
|
||||
$userPreferencesHandler,
|
||||
);
|
||||
$response = $exportController($request);
|
||||
$output = $this->getActualOutputForAssertion();
|
||||
@ -354,11 +369,20 @@ final class ExportControllerTest extends AbstractTestCase
|
||||
COMMIT;
|
||||
SQL;
|
||||
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config),
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
|
||||
$exportController = new ExportController(
|
||||
new ResponseRenderer(),
|
||||
new Export($dbi, new OutputHandler()),
|
||||
ResponseFactory::create(),
|
||||
$config,
|
||||
$userPreferencesHandler,
|
||||
);
|
||||
$response = $exportController($request);
|
||||
$output = $this->getActualOutputForAssertion();
|
||||
@ -508,7 +532,21 @@ final class ExportControllerTest extends AbstractTestCase
|
||||
$export = $container->get(Export::class);
|
||||
(new ReflectionProperty(Export::class, 'dbi'))->setValue($export, $dbi);
|
||||
|
||||
$exportController = new ExportController(new ResponseRenderer(), $export, ResponseFactory::create(), $config);
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config),
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
|
||||
$exportController = new ExportController(
|
||||
new ResponseRenderer(),
|
||||
$export,
|
||||
ResponseFactory::create(),
|
||||
$config,
|
||||
$userPreferencesHandler,
|
||||
);
|
||||
$response = $exportController($request);
|
||||
|
||||
$output = $this->getActualOutputForAssertion();
|
||||
@ -661,7 +699,21 @@ final class ExportControllerTest extends AbstractTestCase
|
||||
$export = $container->get(Export::class);
|
||||
(new ReflectionProperty(Export::class, 'dbi'))->setValue($export, $dbi);
|
||||
|
||||
$exportController = new ExportController(new ResponseRenderer(), $export, ResponseFactory::create(), $config);
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config),
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
|
||||
$exportController = new ExportController(
|
||||
new ResponseRenderer(),
|
||||
$export,
|
||||
ResponseFactory::create(),
|
||||
$config,
|
||||
$userPreferencesHandler,
|
||||
);
|
||||
$response = $exportController($request);
|
||||
|
||||
$output = (string) $response->getBody();
|
||||
|
||||
@ -5,11 +5,17 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Controllers\Navigation;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\Navigation\UpdateNavWidthConfigController;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
@ -23,8 +29,16 @@ final class UpdateNavWidthConfigControllerTest extends AbstractTestCase
|
||||
->withParsedBody(['value' => $value]);
|
||||
|
||||
$config = new Config();
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config),
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$controller = new UpdateNavWidthConfigController($responseRenderer, $config);
|
||||
$controller = new UpdateNavWidthConfigController($responseRenderer, $userPreferencesHandler);
|
||||
$controller($request);
|
||||
|
||||
self::assertSame($expected, $config->settings['NavigationWidth']);
|
||||
@ -48,8 +62,16 @@ final class UpdateNavWidthConfigControllerTest extends AbstractTestCase
|
||||
->withParsedBody(['value' => $value]);
|
||||
|
||||
$config = new Config();
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
new UserPreferences($dbi, new Relation($dbi, $config), new Template($config), $config),
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$controller = new UpdateNavWidthConfigController($responseRenderer, $config);
|
||||
$controller = new UpdateNavWidthConfigController($responseRenderer, $userPreferencesHandler);
|
||||
$controller($request);
|
||||
|
||||
self::assertSame(
|
||||
@ -73,10 +95,10 @@ final class UpdateNavWidthConfigControllerTest extends AbstractTestCase
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/')
|
||||
->withParsedBody(['value' => '240']);
|
||||
|
||||
$config = self::createStub(Config::class);
|
||||
$config->method('setUserValue')->willReturn(Message::error('Could not save configuration'));
|
||||
$userPreferencesHandler = self::createStub(UserPreferencesHandler::class);
|
||||
$userPreferencesHandler->method('setUserValue')->willReturn(Message::error('Could not save configuration'));
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$controller = new UpdateNavWidthConfigController($responseRenderer, $config);
|
||||
$controller = new UpdateNavWidthConfigController($responseRenderer, $userPreferencesHandler);
|
||||
$controller($request);
|
||||
|
||||
self::assertSame(
|
||||
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin\Tests\Controllers;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\NavigationController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -16,7 +17,6 @@ use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\DbiDummy;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
use function sprintf;
|
||||
@ -118,13 +118,13 @@ class NavigationControllerTest extends AbstractTestCase
|
||||
);
|
||||
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$template = new Template();
|
||||
$relation = new Relation($this->dbi);
|
||||
$template = new Template($config);
|
||||
$relation = new Relation($this->dbi, $config);
|
||||
$navigationController = new NavigationController(
|
||||
$responseRenderer,
|
||||
new Navigation($template, $relation, $this->dbi, $config),
|
||||
$relation,
|
||||
new PageSettings(new UserPreferences($this->dbi, $relation, $template)),
|
||||
new PageSettings(new UserPreferences($this->dbi, $relation, $template, $config)),
|
||||
);
|
||||
|
||||
$_POST['full'] = '1';
|
||||
@ -267,13 +267,13 @@ class NavigationControllerTest extends AbstractTestCase
|
||||
);
|
||||
|
||||
$responseRenderer = new ResponseRenderer();
|
||||
$template = new Template();
|
||||
$relation = new Relation($this->dbi);
|
||||
$template = new Template($config);
|
||||
$relation = new Relation($this->dbi, $config);
|
||||
$navigationController = new NavigationController(
|
||||
$responseRenderer,
|
||||
new Navigation($template, $relation, $this->dbi, $config),
|
||||
$relation,
|
||||
new PageSettings(new UserPreferences($this->dbi, $relation, $template)),
|
||||
new PageSettings(new UserPreferences($this->dbi, $relation, $template, $config)),
|
||||
);
|
||||
|
||||
$_POST['full'] = '1';
|
||||
|
||||
@ -6,6 +6,7 @@ namespace PhpMyAdmin\Tests\Controllers\Table;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\Table\ChangeController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -18,7 +19,6 @@ use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
#[CoversClass(ChangeController::class)]
|
||||
@ -43,20 +43,19 @@ final class ChangeControllerTest extends AbstractTestCase
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$response = new ResponseRenderer();
|
||||
$pageSettings = new PageSettings(
|
||||
new UserPreferences($dbi, new Relation($dbi), new Template()),
|
||||
);
|
||||
$config = Config::getInstance();
|
||||
$template = new Template($config);
|
||||
$relation = new Relation($dbi, $config);
|
||||
$userPreferences = new UserPreferences($dbi, $relation, $template, $config);
|
||||
$pageSettings = new PageSettings($userPreferences);
|
||||
$pageSettings->init('Edit');
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('POST', 'http://example.com/')
|
||||
->withQueryParams(['db' => 'test_db', 'table' => 'test_table'])
|
||||
->withParsedBody(['insert_rows' => '0']);
|
||||
|
||||
$config = Config::getInstance();
|
||||
$config->set('InsertRows', 3);
|
||||
|
||||
$relation = new Relation($dbi);
|
||||
$template = new Template();
|
||||
$insertEdit = new InsertEdit(
|
||||
$dbi,
|
||||
$relation,
|
||||
@ -153,22 +152,21 @@ final class ChangeControllerTest extends AbstractTestCase
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$response = new ResponseRenderer();
|
||||
$pageSettings = new PageSettings(
|
||||
new UserPreferences($dbi, new Relation($dbi), new Template()),
|
||||
);
|
||||
$config = Config::getInstance();
|
||||
$relation = new Relation($dbi, $config);
|
||||
$template = new Template($config);
|
||||
$userPreferences = new UserPreferences($dbi, $relation, $template, $config);
|
||||
$pageSettings = new PageSettings($userPreferences);
|
||||
$pageSettings->init('Edit');
|
||||
|
||||
$request = ServerRequestFactory::create()->createServerRequest('GET', 'http://example.com/')
|
||||
->withQueryParams(['db' => 'test_db', 'table' => 'test_table'])
|
||||
->withParsedBody(['insert_rows' => '1']);
|
||||
|
||||
$config = Config::getInstance();
|
||||
$config->set('InsertRows', 3);
|
||||
$config->set('ShowFunctionFields', false);
|
||||
$config->set('ShowFieldTypesInDataEditView', false);
|
||||
|
||||
$relation = new Relation($dbi);
|
||||
$template = new Template();
|
||||
$insertEdit = new InsertEdit(
|
||||
$dbi,
|
||||
$relation,
|
||||
|
||||
@ -6,6 +6,8 @@ namespace PhpMyAdmin\Tests\Controllers\Table;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\Table\ExportController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -15,12 +17,13 @@ use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\Options;
|
||||
use PhpMyAdmin\Export\TemplateModel;
|
||||
use PhpMyAdmin\Http\ServerRequest;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\ExportType;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
#[CoversClass(ExportController::class)]
|
||||
@ -55,11 +58,11 @@ class ExportControllerTest extends AbstractTestCase
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
|
||||
$response = new ResponseRenderer();
|
||||
$pageSettings = new PageSettings(
|
||||
new UserPreferences($dbi, new Relation($dbi), new Template()),
|
||||
);
|
||||
$relation = new Relation($dbi, $config);
|
||||
$template = new Template($config);
|
||||
$userPreferences = new UserPreferences($dbi, $relation, $template, $config);
|
||||
$pageSettings = new PageSettings($userPreferences);
|
||||
$pageSettings->init('Export');
|
||||
$template = new Template();
|
||||
$exportList = Plugins::getExport(ExportType::Table, true);
|
||||
|
||||
$expected = $template->render('table/export/index', [
|
||||
@ -114,11 +117,16 @@ class ExportControllerTest extends AbstractTestCase
|
||||
'page_settings_html' => $pageSettings->getHTML(),
|
||||
]);
|
||||
|
||||
(new ExportController(
|
||||
$response,
|
||||
new Options(new Relation($dbi), new TemplateModel($dbi)),
|
||||
$pageSettings,
|
||||
))(self::createStub(ServerRequest::class));
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
$userPreferences,
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
$options = new Options($relation, new TemplateModel($dbi), $userPreferencesHandler);
|
||||
|
||||
(new ExportController($response, $options, $pageSettings))(self::createStub(ServerRequest::class));
|
||||
self::assertSame($expected, $response->getHTMLResult());
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Controllers\Table;
|
||||
use PhpMyAdmin\Charsets;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\Table\ImportController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -20,7 +21,6 @@ use PhpMyAdmin\Plugins\Import\Upload\UploadNoplugin;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
|
||||
@ -49,11 +49,10 @@ class ImportControllerTest extends AbstractTestCase
|
||||
$choice = Plugins::getChoice($importList, 'xml');
|
||||
$options = Plugins::getOptions('Import', $importList);
|
||||
|
||||
$pageSettings = new PageSettings(
|
||||
new UserPreferences($dbi, new Relation($dbi), new Template()),
|
||||
);
|
||||
$template = new Template($config);
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi, $config), $template, $config);
|
||||
$pageSettings = new PageSettings($userPreferences);
|
||||
$pageSettings->init('Import');
|
||||
$template = new Template();
|
||||
$expected = $template->render('table/import/index', [
|
||||
'page_settings_error_html' => $pageSettings->getErrorHTML(),
|
||||
'page_settings_html' => $pageSettings->getHTML(),
|
||||
|
||||
@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Controllers\Table;
|
||||
use PhpMyAdmin\Bookmarks\BookmarkRepository;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\Table\SqlController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -19,7 +20,6 @@ use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\DbiDummy;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
#[CoversClass(SqlController::class)]
|
||||
@ -51,12 +51,11 @@ class SqlControllerTest extends AbstractTestCase
|
||||
$this->dummyDbi->addSelectDb('test_db');
|
||||
$this->dummyDbi->addResult('SELECT 1 FROM `test_db`.`test_table` LIMIT 1;', [['1']]);
|
||||
|
||||
$pageSettings = new PageSettings(
|
||||
new UserPreferences($this->dbi, new Relation($this->dbi), new Template()),
|
||||
);
|
||||
$template = new Template($config);
|
||||
$userPreferences = new UserPreferences($this->dbi, new Relation($this->dbi, $config), $template, $config);
|
||||
$pageSettings = new PageSettings($userPreferences);
|
||||
$pageSettings->init('Sql');
|
||||
$fields = $this->dbi->getColumns('test_db', 'test_table');
|
||||
$template = new Template();
|
||||
|
||||
$expected = $pageSettings->getHTML();
|
||||
$expected .= $template->render('sql/query', [
|
||||
|
||||
@ -7,6 +7,7 @@ namespace PhpMyAdmin\Tests\Controllers\Table;
|
||||
use PhpMyAdmin\Charsets;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\PageSettings;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Controllers\Table\StructureController;
|
||||
use PhpMyAdmin\Current;
|
||||
@ -19,7 +20,6 @@ use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\DbiDummy;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PhpMyAdmin\Util;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use ReflectionProperty;
|
||||
@ -83,9 +83,10 @@ class StructureControllerTest extends AbstractTestCase
|
||||
);
|
||||
// phpcs:enable
|
||||
|
||||
$pageSettings = new PageSettings(
|
||||
new UserPreferences($this->dbi, new Relation($this->dbi), new Template()),
|
||||
);
|
||||
$relation = new Relation($this->dbi, $config);
|
||||
$template = new Template($config);
|
||||
$userPreferences = new UserPreferences($this->dbi, $relation, $template, $config);
|
||||
$pageSettings = new PageSettings($userPreferences);
|
||||
$pageSettings->init('TableStructure');
|
||||
$fields = $this->dbi->getColumns(Current::$database, Current::$table);
|
||||
|
||||
@ -93,8 +94,6 @@ class StructureControllerTest extends AbstractTestCase
|
||||
->withQueryParams(['route' => '/table/structure', 'db' => 'test_db', 'table' => 'test_table']);
|
||||
|
||||
$response = new ResponseRenderer();
|
||||
$relation = new Relation($this->dbi);
|
||||
$template = new Template();
|
||||
(new StructureController(
|
||||
$response,
|
||||
$template,
|
||||
|
||||
@ -5,13 +5,13 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Controllers;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Controllers\ThemeSetController;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Http\Factory\ServerRequestFactory;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
|
||||
@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests\Export;
|
||||
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
@ -12,9 +14,12 @@ use PhpMyAdmin\Encoding;
|
||||
use PhpMyAdmin\Export\Export;
|
||||
use PhpMyAdmin\Export\Options;
|
||||
use PhpMyAdmin\Export\TemplateModel;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\ExportType;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Tests\AbstractTestCase;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PhpMyAdmin\Util;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
@ -37,10 +42,17 @@ class OptionsTest extends AbstractTestCase
|
||||
Current::$table = 'table';
|
||||
Current::$database = 'PMA';
|
||||
|
||||
$this->export = new Options(
|
||||
new Relation($dbi),
|
||||
new TemplateModel($dbi),
|
||||
$config = Config::getInstance();
|
||||
$relation = new Relation($dbi, $config);
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
new UserPreferences($dbi, $relation, new Template($config), $config),
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
|
||||
$this->export = new Options($relation, new TemplateModel($dbi), $userPreferencesHandler);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
|
||||
@ -6,15 +6,18 @@ namespace PhpMyAdmin\Tests;
|
||||
|
||||
use PhpMyAdmin\Bookmarks\BookmarkRepository;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Console\Console;
|
||||
use PhpMyAdmin\Console\History;
|
||||
use PhpMyAdmin\Current;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Header;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Medium;
|
||||
@ -61,7 +64,14 @@ class HeaderTest extends AbstractTestCase
|
||||
$relation = new Relation($dbi, $config);
|
||||
$template = new Template($config);
|
||||
$history = new History($dbi, $relation, $config);
|
||||
$userPreferences = new UserPreferences($dbi, $relation, $template);
|
||||
$userPreferences = new UserPreferences($dbi, $relation, $template, $config);
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
$userPreferences,
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
|
||||
return new Header(
|
||||
$template,
|
||||
@ -70,6 +80,7 @@ class HeaderTest extends AbstractTestCase
|
||||
$dbi,
|
||||
$relation,
|
||||
$userPreferences,
|
||||
$userPreferencesHandler,
|
||||
);
|
||||
}
|
||||
|
||||
@ -80,12 +91,19 @@ class HeaderTest extends AbstractTestCase
|
||||
$config = Config::getInstance();
|
||||
$dbi = $this->createDatabaseInterface();
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
$relation = new Relation($dbi);
|
||||
$relation = new Relation($dbi, $config);
|
||||
$template = new Template($config);
|
||||
$history = new History($dbi, $relation, $config);
|
||||
$console = new Console($relation, $template, new BookmarkRepository($dbi, $relation), $history);
|
||||
$userPreferences = new UserPreferences($dbi, $relation, $template);
|
||||
$header = new Header($template, $console, $config, $dbi, $relation, $userPreferences);
|
||||
$userPreferences = new UserPreferences($dbi, $relation, $template, $config);
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
$userPreferences,
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
$header = new Header($template, $console, $config, $dbi, $relation, $userPreferences, $userPreferencesHandler);
|
||||
|
||||
$header->setBodyId('PMA_header_id');
|
||||
$actual = $header->getDisplay();
|
||||
|
||||
@ -13,6 +13,8 @@ namespace PhpMyAdmin\Tests\Stubs;
|
||||
|
||||
use PhpMyAdmin\Bookmarks\BookmarkRepository;
|
||||
use PhpMyAdmin\Config;
|
||||
use PhpMyAdmin\Config\UserPreferences;
|
||||
use PhpMyAdmin\Config\UserPreferencesHandler;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Console\Console;
|
||||
use PhpMyAdmin\Console\History;
|
||||
@ -23,9 +25,10 @@ use PhpMyAdmin\Footer;
|
||||
use PhpMyAdmin\Header;
|
||||
use PhpMyAdmin\Http\Factory\ResponseFactory;
|
||||
use PhpMyAdmin\Http\Response;
|
||||
use PhpMyAdmin\I18n\LanguageManager;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
use PhpMyAdmin\Theme\ThemeManager;
|
||||
|
||||
use function is_array;
|
||||
use function json_encode;
|
||||
@ -57,15 +60,22 @@ class ResponseRenderer extends \PhpMyAdmin\ResponseRenderer
|
||||
$dummyDbi = new DbiDummy();
|
||||
$dummyDbi->addSelectDb('phpmyadmin');
|
||||
$dbi = DatabaseInterface::getInstanceForTest($dummyDbi, $config);
|
||||
$relation = new Relation($dbi);
|
||||
$relation = new Relation($dbi, $config);
|
||||
$history = new History($dbi, $relation, $config);
|
||||
$console = new Console($relation, $template, new BookmarkRepository($dbi, $relation), $history);
|
||||
$userPreferences = new UserPreferences($dbi, $relation, $template);
|
||||
$userPreferences = new UserPreferences($dbi, $relation, $template, $config);
|
||||
$userPreferencesHandler = new UserPreferencesHandler(
|
||||
$config,
|
||||
$dbi,
|
||||
$userPreferences,
|
||||
new LanguageManager($config),
|
||||
new ThemeManager(),
|
||||
);
|
||||
|
||||
parent::__construct(
|
||||
$config,
|
||||
$template,
|
||||
new Header($template, $console, $config, $dbi, $relation, $userPreferences),
|
||||
new Header($template, $console, $config, $dbi, $relation, $userPreferences, $userPreferencesHandler),
|
||||
new Footer($template, $config),
|
||||
ErrorHandler::getInstance(),
|
||||
$dbi,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user