Visitar URL original
Merge branch 'QA_5_2' · phpmyadmin/phpmyadmin@a4f8c18 · GitHub
Skip to content

Commit a4f8c18

Browse files
committed
Merge branch 'QA_5_2'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2 parents 4c1c1fc + 5dcd376 commit a4f8c18

15 files changed

Lines changed: 95 additions & 29 deletions

‎ChangeLog‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ phpMyAdmin - ChangeLog
66
5.2.1 (not yet released)
77
- issue #17522 Fix case where the routes cache file is invalid
88
- issue #17506 Fix error when configuring 2FA without XMLWriter or Imagick
9+
- issue Fix blank page when some error occurs
10+
- issue #17519 Fix Export pages not working in certain conditions
911

1012
5.2.0 (2022-05-10)
1113
- issue #16521 Upgrade Bootstrap to version 5

‎js/src/ajax.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,14 @@ var AJAX = {
466466
if (typeof data === 'undefined' || data === null) {
467467
return;
468468
}
469+
// Can be a string when an error occurred and only HTML was returned.
470+
if (typeof data === 'string') {
471+
Functions.ajaxRemoveMessage(AJAX.$msgbox);
472+
Functions.ajaxShowMessage($(data).text(), false, 'error');
473+
AJAX.active = false;
474+
AJAX.xhr = null;
475+
return;
476+
}
469477
if (typeof data.success !== 'undefined' && data.success) {
470478
$('html, body').animate({ scrollTop: 0 }, 'fast');
471479
Functions.ajaxRemoveMessage(AJAX.$msgbox);

‎libraries/classes/ErrorHandler.php‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use function count;
1313
use function defined;
1414
use function error_reporting;
15+
use function get_class;
1516
use function headers_sent;
1617
use function htmlspecialchars;
1718
use function set_error_handler;
@@ -231,18 +232,17 @@ public function handleError(
231232

232233
/**
233234
* Hides exception if it's not in the development environment.
234-
*
235-
* @throws Throwable
236235
*/
237236
public function handleException(Throwable $exception): void
238237
{
239238
$config = $GLOBALS['config'] ?? null;
240-
$environment = $config instanceof Config ? $config->get('environment') : 'production';
241-
if ($environment !== 'development') {
242-
return;
243-
}
244-
245-
throw $exception;
239+
$this->hideLocation = ! $config instanceof Config || $config->get('environment') !== 'development';
240+
$this->addError(
241+
get_class($exception) . ': ' . $exception->getMessage(),
242+
(int) $exception->getCode(),
243+
$exception->getFile(),
244+
$exception->getLine()
245+
);
246246
}
247247

248248
/**
@@ -305,7 +305,9 @@ public function addError(
305305
default:
306306
// FATAL error, display it and exit
307307
$this->dispFatalError($error);
308-
exit;
308+
if (! defined('TESTSUITE')) {
309+
exit;
310+
}
309311
}
310312
}
311313

@@ -336,7 +338,9 @@ protected function dispFatalError(Error $error): void
336338

337339
echo $error->getDisplay();
338340
$this->dispPageEnd();
339-
exit;
341+
if (! defined('TESTSUITE')) {
342+
exit;
343+
}
340344
}
341345

342346
/**

‎libraries/classes/Plugins.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use function count;
3030
use function get_class;
3131
use function htmlspecialchars;
32+
use function is_subclass_of;
3233
use function mb_strpos;
3334
use function mb_strtolower;
3435
use function mb_strtoupper;
@@ -116,8 +117,9 @@ public static function getSchema(): array
116117
* Reads all plugin information
117118
*
118119
* @param string $type the type of the plugin (import, export, etc)
120+
* @psalm-param 'Export'|'Import'|'Schema' $type
119121
*
120-
* @return array list of plugin instances
122+
* @return Plugin[] list of plugin instances
121123
*/
122124
private static function getPlugins(string $type): array
123125
{
@@ -140,7 +142,7 @@ private static function getPlugins(string $type): array
140142
}
141143

142144
$class = sprintf('PhpMyAdmin\\Plugins\\%s\\%s', $type, $fileInfo->getBasename('.php'));
143-
if (! class_exists($class)) {
145+
if (! class_exists($class) || ! is_subclass_of($class, Plugin::class) || ! $class::isAvailable()) {
144146
continue;
145147
}
146148

‎libraries/classes/Plugins/Export/ExportPdf.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ private function setPdf($pdf): void
321321
$this->pdf = $pdf;
322322
}
323323

324-
public function isAvailable(): bool
324+
public static function isAvailable(): bool
325325
{
326326
return class_exists(TCPDF::class);
327327
}

‎libraries/classes/Plugins/Export/ExportXml.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ private function setTables(array $tables): void
541541
$this->tables = $tables;
542542
}
543543

544-
public function isAvailable(): bool
544+
public static function isAvailable(): bool
545545
{
546546
// Can't do server export.
547547
return isset($GLOBALS['db']) && strlen($GLOBALS['db']) > 0;

‎libraries/classes/Plugins/ExportPlugin.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public function getRelationString(
372372
return $relation;
373373
}
374374

375-
public function isAvailable(): bool
375+
public static function isAvailable(): bool
376376
{
377377
return true;
378378
}

‎libraries/classes/Plugins/Import/ImportLdi.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function setProperties(): ImportPluginProperties
4040
$importPluginProperties->setText('CSV using LOAD DATA');
4141
$importPluginProperties->setExtension('ldi');
4242

43-
if (! $this->isAvailable()) {
43+
if (! self::isAvailable()) {
4444
return $importPluginProperties;
4545
}
4646

@@ -194,7 +194,7 @@ public function doImport(?File $importHandle = null): array
194194
return $sqlStatements;
195195
}
196196

197-
public function isAvailable(): bool
197+
public static function isAvailable(): bool
198198
{
199199
// We need relations enabled and we work only on database.
200200
return isset($GLOBALS['plugin_param']) && $GLOBALS['plugin_param'] === 'table';

‎libraries/classes/Plugins/ImportPlugin.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected function getDbnameAndOptions($currentDb, $defaultDb)
9090
];
9191
}
9292

93-
public function isAvailable(): bool
93+
public static function isAvailable(): bool
9494
{
9595
return true;
9696
}

‎libraries/classes/Plugins/Plugin.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ public function getName(): string;
1515

1616
public function getProperties(): PluginPropertyItem;
1717

18-
public function isAvailable(): bool;
18+
public static function isAvailable(): bool;
1919
}

0 commit comments

Comments
 (0)