diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-11-09 20:55:14 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-11-09 20:55:14 +0300 |
commit | 77f9ebb61a9a7f03ddb184d6b5d3b51cc152c001 (patch) | |
tree | 60b0472c41aeaa002585ee80466c72da7c1f5795 /libraries | |
parent | c337b72d5657d33c0f516f93c068d77dfeef5d2f (diff) |
Improve error message when UseDbSearch config is disabled
Replaces Html\Generator::mysqlDie() to avoid calling the exit construct.
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/classes/Controllers/Database/SearchController.php | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/libraries/classes/Controllers/Database/SearchController.php b/libraries/classes/Controllers/Database/SearchController.php index 07ab737a03..0fb26dab85 100644 --- a/libraries/classes/Controllers/Database/SearchController.php +++ b/libraries/classes/Controllers/Database/SearchController.php @@ -7,8 +7,9 @@ namespace PhpMyAdmin\Controllers\Database; use PhpMyAdmin\Controllers\AbstractController; use PhpMyAdmin\Database\Search; use PhpMyAdmin\DatabaseInterface; -use PhpMyAdmin\Html\Generator; +use PhpMyAdmin\Html\MySQLDocumentation; use PhpMyAdmin\Http\ServerRequest; +use PhpMyAdmin\Message; use PhpMyAdmin\ResponseRenderer; use PhpMyAdmin\Template; use PhpMyAdmin\Url; @@ -49,14 +50,21 @@ class SearchController extends AbstractController return; } - // If config variable $cfg['UseDbSearch'] is on false : exit. if (! $GLOBALS['cfg']['UseDbSearch']) { - Generator::mysqlDie( - __('Access denied!'), - '', - false, - $GLOBALS['errorUrl'] + $errorMessage = __( + 'Searching inside the database is disabled by the [code]$cfg[\'UseDbSearch\'][/code] configuration.' ); + $errorMessage .= MySQLDocumentation::showDocumentation('config', 'cfg_UseDbSearch'); + $this->response->setRequestStatus(false); + if ($this->response->isAjax()) { + $this->response->addJSON('message', Message::error($errorMessage)->getDisplay()); + + return; + } + + $this->render('error/simple', ['error_message' => $errorMessage, 'back_url' => $GLOBALS['errorUrl']]); + + return; } $GLOBALS['urlParams']['goto'] = Url::getFromRoute('/database/search'); |