3 declare(strict_types
=1);
5 namespace PhpMyAdmin\Controllers
;
8 use PhpMyAdmin\ConfigStorage\Relation
;
9 use PhpMyAdmin\Current
;
10 use PhpMyAdmin\Http\Response
;
11 use PhpMyAdmin\Http\ServerRequest
;
12 use PhpMyAdmin\Identifiers\DatabaseName
;
13 use PhpMyAdmin\ResponseRenderer
;
18 * Displays status of phpMyAdmin configuration storage
20 final class CheckRelationsController
implements InvocableController
22 public function __construct(private readonly ResponseRenderer
$response, private readonly Relation
$relation)
26 public function __invoke(ServerRequest
$request): Response|
null
28 $cfgStorageDbName = $this->relation
->getConfigurationStorageDbName();
30 $db = DatabaseName
::tryFrom(Current
::$database);
32 // If request for creating the pmadb
33 if ($request->hasBodyParam('create_pmadb') && $this->relation
->createPmaDatabase($cfgStorageDbName)) {
34 $this->relation
->fixPmaTables($cfgStorageDbName);
37 // If request for creating all PMA tables.
38 if ($request->hasBodyParam('fixall_pmadb') && $db !== null) {
39 $this->relation
->fixPmaTables($db->getName());
42 // If request for creating missing PMA tables.
43 if ($request->hasBodyParam('fix_pmadb')) {
44 $relationParameters = $this->relation
->getRelationParameters();
45 $this->relation
->fixPmaTables((string) $relationParameters->db
);
48 // Do not use any previous $relationParameters value as it could have changed after a successful fixPmaTables()
49 $relationParameters = $this->relation
->getRelationParameters();
51 $this->response
->render('relation/check_relations', [
52 'db' => $db?
->getName() ??
'',
53 'zero_conf' => Config
::getInstance()->settings
['ZeroConf'],
54 'relation_parameters' => $relationParameters->toArray(),
56 'config_storage_database_name' => $cfgStorageDbName,
57 'are_config_storage_tables_defined' => $this->relation
->arePmadbTablesDefined(),