Skip to content

Commit

Permalink
Clean up is_foreign_key_supported
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
  • Loading branch information
kamil-tekiela authored and MauricioFauth committed Mar 4, 2023
1 parent a101587 commit 20a2462
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
5 changes: 2 additions & 3 deletions libraries/classes/Controllers/Table/RelationController.php
Expand Up @@ -58,7 +58,7 @@ public function __invoke(ServerRequest $request): void
];

$table = $this->dbi->getTable($GLOBALS['db'], $GLOBALS['table']);
$storageEngine = mb_strtoupper((string) $table->getStatusInfo('Engine'));
$storageEngine = $table->getStorageEngine();

$relationParameters = $this->relation->getRelationParameters();

Expand Down Expand Up @@ -198,9 +198,8 @@ public function __invoke(ServerRequest $request): void
]);

// common form
$engine = $this->dbi->getTable($GLOBALS['db'], $GLOBALS['table'])->getStorageEngine();
$this->render('table/relation/common_form', [
'is_foreign_key_supported' => ForeignKey::isSupported($engine),
'is_foreign_key_supported' => ForeignKey::isSupported($storageEngine),
'db' => $GLOBALS['db'],
'table' => $GLOBALS['table'],
'relation_parameters' => $relationParameters,
Expand Down
5 changes: 0 additions & 5 deletions libraries/classes/Twig/UtilExtension.php
Expand Up @@ -7,7 +7,6 @@
use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Html\MySQLDocumentation;
use PhpMyAdmin\Util;
use PhpMyAdmin\Utils\ForeignKey;
use PhpMyAdmin\Utils\Gis;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
Expand Down Expand Up @@ -86,10 +85,6 @@ public function getFunctions(): array
'is_uuid_supported',
Util::isUUIDSupported(...),
),
new TwigFunction(
'is_foreign_key_supported',
ForeignKey::isSupported(...),
),
new TwigFunction(
'link_or_button',
Generator::linkOrButton(...),
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Expand Up @@ -2280,11 +2280,6 @@ parameters:
count: 1
path: libraries/classes/Controllers/Table/IndexesController.php

-
message: "#^Cannot cast mixed to string\\.$#"
count: 1
path: libraries/classes/Controllers/Table/RelationController.php

-
message: "#^Method PhpMyAdmin\\\\Controllers\\\\Table\\\\RelationController\\:\\:updateForForeignKeys\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
8 changes: 4 additions & 4 deletions templates/table/relation/common_form.twig
Expand Up @@ -4,7 +4,7 @@
<form method="post" action="{{ url('/table/relation') }}">
{{ get_hidden_inputs(db, table) }}
{# InnoDB #}
{% if is_foreign_key_supported(tbl_storage_engine) %}
{% if is_foreign_key_supported %}
<fieldset class="pma-fieldset mb-3">
<legend>{% trans 'Foreign key constraints' %}</legend>
<div class="table-responsive-md jsresponsive">
Expand Down Expand Up @@ -51,7 +51,7 @@
{% endif %}

{% if relation_parameters.relationFeature is not null %}
{% if default_sliders_state != 'disabled' and is_foreign_key_supported(tbl_storage_engine) %}
{% if default_sliders_state != 'disabled' and is_foreign_key_supported %}
<div class="mb-3">
<button class="btn btn-sm btn-secondary" type="button" data-bs-toggle="collapse" data-bs-target="#internalRelationships" aria-expanded="{{ default_sliders_state == 'open' ? 'true' : 'false' }}" aria-controls="internalRelationships">
{% trans 'Internal relationships' %}
Expand All @@ -71,7 +71,7 @@
<th>{% trans 'Column' %}</th>
<th>
{% trans 'Internal relation' %}
{% if is_foreign_key_supported(tbl_storage_engine) %}
{% if is_foreign_key_supported %}
{{ show_hint('An internal relation is not necessary when a corresponding FOREIGN KEY relation exists.'|trans) }}
{% endif %}
</th>
Expand Down Expand Up @@ -148,7 +148,7 @@
</tbody>
</table>
</fieldset>
{% if default_sliders_state != 'disabled' and is_foreign_key_supported(tbl_storage_engine) %}
{% if default_sliders_state != 'disabled' and is_foreign_key_supported %}
</div>
{% endif %}
{% endif %}
Expand Down

0 comments on commit 20a2462

Please sign in to comment.