Skip to content

Commit d42db65

Browse files
Merge pull request #19768 from MauricioFauth/navi-settings-const
Remove the PMA_DISABLE_NAVI_SETTINGS constant
2 parents 46d7130 + 68281c9 commit d42db65

9 files changed

Lines changed: 20 additions & 19 deletions

src/Controllers/Preferences/ExportController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
use PhpMyAdmin\Http\Response;
1414
use PhpMyAdmin\Http\ServerRequest;
1515
use PhpMyAdmin\Message;
16+
use PhpMyAdmin\Navigation\Navigation;
1617
use PhpMyAdmin\ResponseRenderer;
1718
use PhpMyAdmin\Routing\Route;
1819
use PhpMyAdmin\Theme\ThemeManager;
1920
use PhpMyAdmin\TwoFactor;
2021
use PhpMyAdmin\Url;
2122
use PhpMyAdmin\UserPreferences;
2223

23-
use function define;
2424
use function ltrim;
2525

2626
#[Route('/preferences/export', ['GET', 'POST'])]
@@ -90,7 +90,7 @@ public function __invoke(ServerRequest $request): Response
9090
if ($request->isAjax()) {
9191
$this->response->addJSON('disableNaviSettings', true);
9292
} else {
93-
define('PMA_DISABLE_NAVI_SETTINGS', true);
93+
Navigation::$isSettingsEnabled = false;
9494
}
9595

9696
return $this->response->response();

src/Controllers/Preferences/FeaturesController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
use PhpMyAdmin\Http\Response;
1414
use PhpMyAdmin\Http\ServerRequest;
1515
use PhpMyAdmin\Message;
16+
use PhpMyAdmin\Navigation\Navigation;
1617
use PhpMyAdmin\ResponseRenderer;
1718
use PhpMyAdmin\Routing\Route;
1819
use PhpMyAdmin\Theme\ThemeManager;
1920
use PhpMyAdmin\TwoFactor;
2021
use PhpMyAdmin\Url;
2122
use PhpMyAdmin\UserPreferences;
2223

23-
use function define;
2424
use function ltrim;
2525

2626
#[Route('/preferences/features', ['GET', 'POST'])]
@@ -90,7 +90,7 @@ public function __invoke(ServerRequest $request): Response
9090
if ($request->isAjax()) {
9191
$this->response->addJSON('disableNaviSettings', true);
9292
} else {
93-
define('PMA_DISABLE_NAVI_SETTINGS', true);
93+
Navigation::$isSettingsEnabled = false;
9494
}
9595

9696
return $this->response->response();

src/Controllers/Preferences/ImportController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
use PhpMyAdmin\Http\Response;
1414
use PhpMyAdmin\Http\ServerRequest;
1515
use PhpMyAdmin\Message;
16+
use PhpMyAdmin\Navigation\Navigation;
1617
use PhpMyAdmin\ResponseRenderer;
1718
use PhpMyAdmin\Routing\Route;
1819
use PhpMyAdmin\Theme\ThemeManager;
1920
use PhpMyAdmin\TwoFactor;
2021
use PhpMyAdmin\Url;
2122
use PhpMyAdmin\UserPreferences;
2223

23-
use function define;
2424
use function ltrim;
2525

2626
#[Route('/preferences/import', ['GET', 'POST'])]
@@ -90,7 +90,7 @@ public function __invoke(ServerRequest $request): Response
9090
if ($request->isAjax()) {
9191
$this->response->addJSON('disableNaviSettings', true);
9292
} else {
93-
define('PMA_DISABLE_NAVI_SETTINGS', true);
93+
Navigation::$isSettingsEnabled = false;
9494
}
9595

9696
return $this->response->response();

src/Controllers/Preferences/MainPanelController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
use PhpMyAdmin\Http\Response;
1414
use PhpMyAdmin\Http\ServerRequest;
1515
use PhpMyAdmin\Message;
16+
use PhpMyAdmin\Navigation\Navigation;
1617
use PhpMyAdmin\ResponseRenderer;
1718
use PhpMyAdmin\Routing\Route;
1819
use PhpMyAdmin\Theme\ThemeManager;
1920
use PhpMyAdmin\TwoFactor;
2021
use PhpMyAdmin\Url;
2122
use PhpMyAdmin\UserPreferences;
2223

23-
use function define;
2424
use function ltrim;
2525

2626
#[Route('/preferences/main-panel', ['GET', 'POST'])]
@@ -90,7 +90,7 @@ public function __invoke(ServerRequest $request): Response
9090
if ($request->isAjax()) {
9191
$this->response->addJSON('disableNaviSettings', true);
9292
} else {
93-
define('PMA_DISABLE_NAVI_SETTINGS', true);
93+
Navigation::$isSettingsEnabled = false;
9494
}
9595

9696
return $this->response->response();

src/Controllers/Preferences/ManageController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use PhpMyAdmin\Http\Response;
1717
use PhpMyAdmin\Http\ServerRequest;
1818
use PhpMyAdmin\Message;
19+
use PhpMyAdmin\Navigation\Navigation;
1920
use PhpMyAdmin\ResponseRenderer;
2021
use PhpMyAdmin\Routing\Route;
2122
use PhpMyAdmin\Theme\ThemeManager;
@@ -24,7 +25,6 @@
2425

2526
use function __;
2627
use function array_merge;
27-
use function define;
2828
use function file_exists;
2929
use function is_array;
3030
use function is_string;
@@ -254,7 +254,7 @@ public function __invoke(ServerRequest $request): Response
254254
if ($request->isAjax()) {
255255
$this->response->addJSON('disableNaviSettings', true);
256256
} else {
257-
define('PMA_DISABLE_NAVI_SETTINGS', true);
257+
Navigation::$isSettingsEnabled = false;
258258
}
259259

260260
return $this->response->response();

src/Controllers/Preferences/NavigationController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
use PhpMyAdmin\Http\Response;
1414
use PhpMyAdmin\Http\ServerRequest;
1515
use PhpMyAdmin\Message;
16+
use PhpMyAdmin\Navigation\Navigation;
1617
use PhpMyAdmin\ResponseRenderer;
1718
use PhpMyAdmin\Routing\Route;
1819
use PhpMyAdmin\Theme\ThemeManager;
1920
use PhpMyAdmin\TwoFactor;
2021
use PhpMyAdmin\Url;
2122
use PhpMyAdmin\UserPreferences;
2223

23-
use function define;
2424
use function ltrim;
2525

2626
#[Route('/preferences/navigation', ['GET', 'POST'])]
@@ -93,7 +93,7 @@ public function __invoke(ServerRequest $request): Response
9393
return $this->response->response();
9494
}
9595

96-
define('PMA_DISABLE_NAVI_SETTINGS', true);
96+
Navigation::$isSettingsEnabled = false;
9797

9898
return $this->response->response();
9999
}

src/Controllers/Preferences/SqlController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
use PhpMyAdmin\Http\Response;
1414
use PhpMyAdmin\Http\ServerRequest;
1515
use PhpMyAdmin\Message;
16+
use PhpMyAdmin\Navigation\Navigation;
1617
use PhpMyAdmin\ResponseRenderer;
1718
use PhpMyAdmin\Routing\Route;
1819
use PhpMyAdmin\Theme\ThemeManager;
1920
use PhpMyAdmin\TwoFactor;
2021
use PhpMyAdmin\Url;
2122
use PhpMyAdmin\UserPreferences;
2223

23-
use function define;
2424
use function ltrim;
2525

2626
#[Route('/preferences/sql', ['GET', 'POST'])]
@@ -90,7 +90,7 @@ public function __invoke(ServerRequest $request): Response
9090
if ($request->isAjax()) {
9191
$this->response->addJSON('disableNaviSettings', true);
9292
} else {
93-
define('PMA_DISABLE_NAVI_SETTINGS', true);
93+
Navigation::$isSettingsEnabled = false;
9494
}
9595

9696
return $this->response->response();

src/Controllers/Preferences/TwoFactorController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
use PhpMyAdmin\Http\Response;
1111
use PhpMyAdmin\Http\ServerRequest;
1212
use PhpMyAdmin\Message;
13+
use PhpMyAdmin\Navigation\Navigation;
1314
use PhpMyAdmin\ResponseRenderer;
1415
use PhpMyAdmin\Routing\Route;
1516
use PhpMyAdmin\TwoFactor;
1617

1718
use function __;
1819
use function count;
19-
use function define;
2020

2121
#[Route('/preferences/two-factor', ['GET', 'POST'])]
2222
final readonly class TwoFactorController implements InvocableController
@@ -77,7 +77,7 @@ public function __invoke(ServerRequest $request): Response
7777
if ($request->isAjax()) {
7878
$this->response->addJSON('disableNaviSettings', true);
7979
} else {
80-
define('PMA_DISABLE_NAVI_SETTINGS', true);
80+
Navigation::$isSettingsEnabled = false;
8181
}
8282

8383
return $this->response->response();

src/Navigation/Navigation.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
use function __;
2929
use function count;
30-
use function defined;
3130
use function file_exists;
3231
use function parse_url;
3332
use function str_contains;
@@ -40,6 +39,8 @@
4039
*/
4140
class Navigation
4241
{
42+
public static bool $isSettingsEnabled = true;
43+
4344
private NavigationTree $tree;
4445
private readonly UserPrivilegesFactory $userPrivilegesFactory;
4546

@@ -98,7 +99,7 @@ public function getDisplay(): string
9899
$serverSelect = Select::render(true);
99100
}
100101

101-
if (! defined('PMA_DISABLE_NAVI_SETTINGS')) {
102+
if (self::$isSettingsEnabled) {
102103
$pageSettings = new PageSettings(
103104
new UserPreferences($this->dbi, new Relation($this->dbi), $this->template),
104105
);
@@ -133,7 +134,7 @@ public function getDisplay(): string
133134
'servers' => $this->config->settings['Servers'],
134135
'server_select' => $serverSelect ?? '',
135136
'navigation_tree' => $navRender,
136-
'is_navigation_settings_enabled' => ! defined('PMA_DISABLE_NAVI_SETTINGS'),
137+
'is_navigation_settings_enabled' => self::$isSettingsEnabled,
137138
'navigation_settings' => $navigationSettings ?? '',
138139
'is_drag_drop_import_enabled' => $this->config->settings['enable_drag_drop_import'] === true,
139140
'is_mariadb' => $this->dbi->isMariaDB(),

0 commit comments

Comments
 (0)