Skip to content

Commit e16682d

Browse files
committed
Remove IS_TRANSFORMATION_WRAPPER constant
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 754e15e commit e16682d

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

libraries/classes/Controllers/Transformation/WrapperController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use PhpMyAdmin\Util;
1717

1818
use function __;
19-
use function define;
2019
use function htmlspecialchars;
2120
use function in_array;
2221
use function intval;
@@ -54,11 +53,11 @@ public function __construct(
5453

5554
public function __invoke(): void
5655
{
57-
define('IS_TRANSFORMATION_WRAPPER', true);
56+
$this->response->getHeader()->setIsTransformationWrapper(true);
5857

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

61-
DbTableExists::check($GLOBALS['db'], $GLOBALS['table']);
60+
DbTableExists::check($GLOBALS['db'], $GLOBALS['table'], true);
6261

6362
/**
6463
* Sets globals from $_REQUEST

libraries/classes/DbTableExists.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ final class DbTableExists
1414
/**
1515
* Ensure the database and the table exist (else move to the "parent" script) and display headers.
1616
*/
17-
public static function check(string $db, string $table): void
17+
public static function check(string $db, string $table, bool $isTransformationWrapper = false): void
1818
{
19-
self::checkDatabase($db);
20-
self::checkTable($db, $table);
19+
self::checkDatabase($db, $isTransformationWrapper);
20+
self::checkTable($db, $table, $isTransformationWrapper);
2121
}
2222

23-
private static function checkDatabase(string $db): void
23+
private static function checkDatabase(string $db, bool $isTransformationWrapper): void
2424
{
2525
if (! empty($GLOBALS['is_db'])) {
2626
return;
@@ -31,7 +31,7 @@ private static function checkDatabase(string $db): void
3131
$GLOBALS['is_db'] = @$GLOBALS['dbi']->selectDb($db);
3232
}
3333

34-
if ($GLOBALS['is_db'] || defined('IS_TRANSFORMATION_WRAPPER')) {
34+
if ($GLOBALS['is_db'] || $isTransformationWrapper) {
3535
return;
3636
}
3737

@@ -65,7 +65,7 @@ private static function checkDatabase(string $db): void
6565
exit;
6666
}
6767

68-
private static function checkTable(string $db, string $table): void
68+
private static function checkTable(string $db, string $table, bool $isTransformationWrapper): void
6969
{
7070
if (! empty($GLOBALS['is_table']) || defined('PMA_SUBMIT_MULT') || defined('TABLE_MAY_BE_ABSENT')) {
7171
return;
@@ -86,7 +86,7 @@ private static function checkTable(string $db, string $table): void
8686
return;
8787
}
8888

89-
if (defined('IS_TRANSFORMATION_WRAPPER')) {
89+
if ($isTransformationWrapper) {
9090
exit;
9191
}
9292

libraries/classes/Header.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ class Header
9797
/** @var Template */
9898
private $template;
9999

100+
/** @var bool */
101+
private $isTransformationWrapper = false;
102+
100103
/**
101104
* Creates a new class instance
102105
*/
@@ -522,7 +525,10 @@ private function getHttpHeaders(): array
522525

523526
$headers = array_merge($headers, Core::getNoCacheHeaders());
524527

525-
if (! defined('IS_TRANSFORMATION_WRAPPER')) {
528+
/**
529+
* A different Content-Type is set in {@see \PhpMyAdmin\Controllers\Transformation\WrapperController}.
530+
*/
531+
if (! $this->isTransformationWrapper) {
526532
// Define the charset to be used
527533
$headers['Content-Type'] = 'text/html; charset=utf-8';
528534
}
@@ -666,4 +672,9 @@ private function getVariablesForJavaScript(): string
666672
'max_input_vars' => $maxInputVarsValue,
667673
]);
668674
}
675+
676+
public function setIsTransformationWrapper(bool $isTransformationWrapper): void
677+
{
678+
$this->isTransformationWrapper = $isTransformationWrapper;
679+
}
669680
}

0 commit comments

Comments
 (0)