From 76aabc98269cfd74f43d1079de7a304177fe8fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 2 Jul 2021 01:29:07 -0300 Subject: [PATCH] Remove `PMA_MINIMUM_COMMON` constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces it with the `$isMinimumCommon` global variable. Signed-off-by: MaurĂ­cio Meneghini Fauth --- js/messages.php | 2 +- libraries/classes/Config.php | 7 +++++-- libraries/common.inc.php | 6 ++---- setup/lib/common.inc.php | 8 +++----- url.php | 4 +--- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/js/messages.php b/js/messages.php index a99463b7da..7901904d75 100644 --- a/js/messages.php +++ b/js/messages.php @@ -22,8 +22,8 @@ header('Content-Type: text/javascript; charset=UTF-8'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT'); // Avoid loading the full common.inc.php because this would add many non-js-compatible stuff like DOCTYPE. +$isMinimumCommon = true; // phpcs:disable PSR1.Files.SideEffects -define('PMA_MINIMUM_COMMON', true); define('PMA_PATH_TO_BASEDIR', '../'); define('PMA_NO_SESSION', true); // phpcs:enable diff --git a/libraries/classes/Config.php b/libraries/classes/Config.php index 8feb6d2648..84eb78facd 100644 --- a/libraries/classes/Config.php +++ b/libraries/classes/Config.php @@ -532,6 +532,8 @@ class Config */ public function loadUserPreferences(): void { + global $isMinimumCommon; + $userPreferences = new UserPreferences(); // index.php should load these settings, so that phpmyadmin.css.php // will have everything available in session cache @@ -539,7 +541,7 @@ class Config ? $GLOBALS['cfg']['ServerDefault'] : 0); $cache_key = 'server_' . $server; - if ($server > 0 && ! defined('PMA_MINIMUM_COMMON')) { + if ($server > 0 && ! isset($isMinimumCommon)) { $config_mtime = max($this->defaultSourceMtime, $this->sourceMtime); // cache user preferences, use database only when needed if ( @@ -575,7 +577,8 @@ class Config // load config array $this->settings = array_replace_recursive($this->settings, $config_data); $GLOBALS['cfg'] = array_replace_recursive($GLOBALS['cfg'], $config_data); - if (defined('PMA_MINIMUM_COMMON')) { + + if (isset($isMinimumCommon)) { return; } diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 23fb2f99f7..a5b773a43c 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -110,9 +110,7 @@ if (! defined('K_PATH_IMAGES')) { $route = Routing::getCurrentRoute(); if ($route === '/import-status') { - // phpcs:disable PSR1.Files.SideEffects - define('PMA_MINIMUM_COMMON', true); - // phpcs:enable + $isMinimumCommon = true; } $containerBuilder = Core::getContainerBuilder(); @@ -238,7 +236,7 @@ $theme = ThemeManager::initializeTheme(); /** @var DatabaseInterface $dbi */ $dbi = null; -if (defined('PMA_MINIMUM_COMMON')) { +if (isset($isMinimumCommon)) { $config->loadUserPreferences(); $containerBuilder->set('theme_manager', ThemeManager::getInstance()); Tracker::enable(); diff --git a/setup/lib/common.inc.php b/setup/lib/common.inc.php index 573f1fb1e6..de86b2dfdd 100644 --- a/setup/lib/common.inc.php +++ b/setup/lib/common.inc.php @@ -8,22 +8,20 @@ declare(strict_types=1); use PhpMyAdmin\Config\ConfigFile; use PhpMyAdmin\DatabaseInterface; -// phpcs:disable PSR1.Files.SideEffects -define('PMA_MINIMUM_COMMON', true); -// phpcs:enable - chdir('..'); if (! file_exists(ROOT_PATH . 'libraries/common.inc.php')) { die('Bad invocation!'); } +$isMinimumCommon = true; + require_once ROOT_PATH . 'libraries/common.inc.php'; // use default error handler restore_error_handler(); -// Save current language in a cookie, required since we use PMA_MINIMUM_COMMON +// Save current language in a cookie, required since we set $isMinimumCommon $GLOBALS['config']->setCookie('pma_lang', (string) $GLOBALS['lang']); $GLOBALS['config']->set('is_setup', true); diff --git a/url.php b/url.php index abc9b18f2a..7332a026b1 100644 --- a/url.php +++ b/url.php @@ -18,9 +18,7 @@ if (! defined('ROOT_PATH')) { global $containerBuilder, $dbi; -// phpcs:disable PSR1.Files.SideEffects -define('PMA_MINIMUM_COMMON', true); -// phpcs:enable +$isMinimumCommon = true; require_once ROOT_PATH . 'libraries/common.inc.php';