Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurício Meneghini Fauth <mauricio@fauth.dev>2022-03-31 04:13:54 +0300
committerMaurício Meneghini Fauth <mauricio@fauth.dev>2022-09-26 23:33:38 +0300
commit0ed04a6c00423cc5eeffef19558d7598e96fd82f (patch)
tree05c019a5a9ac78871a6d5ca7b9d49febced5b3a3 /libraries
parent893d4cddb67f671ec84a6b600a633974845877a1 (diff)
Remove `trigger_error` calls from `HomeController`
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev> (cherry picked from commit c5611531c03a5c9dfe13510e7fc5b901daa77039) Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'libraries')
-rw-r--r--libraries/classes/Controllers/HomeController.php103
1 files changed, 54 insertions, 49 deletions
diff --git a/libraries/classes/Controllers/HomeController.php b/libraries/classes/Controllers/HomeController.php
index 322ed3702e..998cc3b4ce 100644
--- a/libraries/classes/Controllers/HomeController.php
+++ b/libraries/classes/Controllers/HomeController.php
@@ -30,10 +30,7 @@ use function ini_get;
use function mb_strlen;
use function preg_match;
use function sprintf;
-use function trigger_error;
-use const E_USER_NOTICE;
-use const E_USER_WARNING;
use const PHP_VERSION;
use const SODIUM_CRYPTO_SECRETBOX_KEYBYTES;
@@ -48,6 +45,12 @@ class HomeController extends AbstractController
/** @var DatabaseInterface */
private $dbi;
+ /**
+ * @var array<int, array<string, string>>
+ * @psalm-var list<array{message: string, severity: 'warning'|'notice'}>
+ */
+ private $errors = [];
+
public function __construct(
ResponseRenderer $response,
Template $template,
@@ -241,6 +244,7 @@ class HomeController extends AbstractController
'config_storage_message' => $configStorageMessage ?? '',
'has_theme_manager' => $cfg['ThemeManager'],
'themes' => $this->themeManager->getThemesArray(),
+ 'errors' => $this->errors,
]);
}
@@ -256,16 +260,16 @@ class HomeController extends AbstractController
*/
$gc_time = (int) ini_get('session.gc_maxlifetime');
if ($gc_time < $cfg['LoginCookieValidity']) {
- trigger_error(
- __(
+ $this->errors[] = [
+ 'message' => __(
'Your PHP parameter [a@https://www.php.net/manual/en/session.' .
'configuration.php#ini.session.gc-maxlifetime@_blank]session.' .
'gc_maxlifetime[/a] is lower than cookie validity configured ' .
'in phpMyAdmin, because of this, your login might expire sooner ' .
'than configured in phpMyAdmin.'
),
- E_USER_WARNING
- );
+ 'severity' => 'warning',
+ ];
}
}
@@ -273,14 +277,14 @@ class HomeController extends AbstractController
* Check whether LoginCookieValidity is limited by LoginCookieStore.
*/
if ($cfg['LoginCookieStore'] != 0 && $cfg['LoginCookieStore'] < $cfg['LoginCookieValidity']) {
- trigger_error(
- __(
+ $this->errors[] = [
+ 'message' => __(
'Login cookie store is lower than cookie validity configured in ' .
'phpMyAdmin, because of this, your login will expire sooner than ' .
'configured in phpMyAdmin.'
),
- E_USER_WARNING
- );
+ 'severity' => 'warning',
+ ];
}
/**
@@ -292,15 +296,15 @@ class HomeController extends AbstractController
&& $cfg['Server']['controluser'] === 'pma'
&& $cfg['Server']['controlpass'] === 'pmapass'
) {
- trigger_error(
- __(
+ $this->errors[] = [
+ 'message' => __(
'Your server is running with default values for the ' .
'controluser and password (controlpass) and is open to ' .
'intrusion; you really should fix this security weakness' .
' by changing the password for controluser \'pma\'.'
),
- E_USER_WARNING
- );
+ 'severity' => 'warning',
+ ];
}
/**
@@ -308,23 +312,23 @@ class HomeController extends AbstractController
*/
if (! empty($_SESSION['encryption_key'])) {
if (empty($cfg['blowfish_secret'])) {
- trigger_error(
- __(
+ $this->errors[] = [
+ 'message' => __(
'The configuration file now needs a secret passphrase (blowfish_secret).'
),
- E_USER_WARNING
- );
+ 'severity' => 'warning',
+ ];
} elseif (mb_strlen($cfg['blowfish_secret'], '8bit') !== SODIUM_CRYPTO_SECRETBOX_KEYBYTES) {
- trigger_error(
- sprintf(
+ $this->errors[] = [
+ 'message' => sprintf(
__(
'The secret passphrase in configuration (blowfish_secret) is not the correct length.'
. ' It should be %d bytes long.'
),
SODIUM_CRYPTO_SECRETBOX_KEYBYTES
),
- E_USER_WARNING
- );
+ 'severity' => 'warning',
+ ];
}
}
@@ -333,16 +337,16 @@ class HomeController extends AbstractController
* production environment.
*/
if (@file_exists(ROOT_PATH . 'config')) {
- trigger_error(
- __(
+ $this->errors[] = [
+ 'message' => __(
'Directory [code]config[/code], which is used by the setup script, ' .
'still exists in your phpMyAdmin directory. It is strongly ' .
'recommended to remove it once phpMyAdmin has been configured. ' .
'Otherwise the security of your server may be compromised by ' .
'unauthorized people downloading your configuration.'
),
- E_USER_WARNING
- );
+ 'severity' => 'warning',
+ ];
}
/**
@@ -353,22 +357,22 @@ class HomeController extends AbstractController
&& ini_get('suhosin.request.max_value_length')
&& ini_get('suhosin.simulation') == '0'
) {
- trigger_error(
- sprintf(
+ $this->errors[] = [
+ 'message' => sprintf(
__(
'Server running with Suhosin. Please refer to %sdocumentation%s for possible issues.'
),
'[doc@faq1-38]',
'[/doc]'
),
- E_USER_WARNING
- );
+ 'severity' => 'warning',
+ ];
}
/* Missing template cache */
if ($this->config->getTempDir('twig') === null) {
- trigger_error(
- sprintf(
+ $this->errors[] = [
+ 'message' => sprintf(
__(
'The $cfg[\'TempDir\'] (%s) is not accessible. ' .
'phpMyAdmin is not able to cache templates and will ' .
@@ -376,8 +380,8 @@ class HomeController extends AbstractController
),
$this->config->get('TempDir')
),
- E_USER_WARNING
- );
+ 'severity' => 'warning',
+ ];
}
$this->checkLanguageStats();
@@ -410,12 +414,12 @@ class HomeController extends AbstractController
return;
}
- trigger_error(
- 'You are using an incomplete translation, please help to make it '
- . 'better by [a@https://www.phpmyadmin.net/translate/'
- . '@_blank]contributing[/a].',
- E_USER_NOTICE
- );
+ $this->errors[] = [
+ 'message' => 'You are using an incomplete translation, please help to make it '
+ . 'better by [a@https://www.phpmyadmin.net/translate/'
+ . '@_blank]contributing[/a].',
+ 'severity' => 'notice',
+ ];
}
private function checkPhpExtensionsRequirements(): void
@@ -425,15 +429,15 @@ class HomeController extends AbstractController
* to tell user something might be broken without it, see bug #1063149.
*/
if (! extension_loaded('mbstring')) {
- trigger_error(
- __(
+ $this->errors[] = [
+ 'message' => __(
'The mbstring PHP extension was not found and you seem to be using'
. ' a multibyte charset. Without the mbstring extension phpMyAdmin'
. ' is unable to split strings correctly and it may result in'
. ' unexpected results.'
),
- E_USER_WARNING
- );
+ 'severity' => 'warning',
+ ];
}
/**
@@ -443,12 +447,13 @@ class HomeController extends AbstractController
return;
}
- trigger_error(
- __(
+ $this->errors[] = [
+ 'message' => __(
'The curl extension was not found and allow_url_fopen is '
. 'disabled. Due to this some features such as error reporting '
. 'or version check are disabled.'
- )
- );
+ ),
+ 'severity' => 'notice',
+ ];
}
}