Merge pull request #15544 from Tithugues/code-cleaning

Replace fake loop by try/catch with exceptions
This commit is contained in:
Maurício Meneghini Fauth 2019-11-01 20:30:18 -03:00 committed by GitHub
commit 0bdd1ff988
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 7 deletions

View File

@ -0,0 +1,21 @@
<?php
/**
* Export exception
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
namespace PhpMyAdmin\Exceptions;
use Exception;
/**
* Export exception
*
* @package PhpMyAdmin
*/
class ExportException extends Exception
{
}

View File

@ -9,6 +9,7 @@ declare(strict_types=1);
use PhpMyAdmin\Core;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Encoding;
use PhpMyAdmin\Exceptions\ExportException;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportPlugin;
@ -433,16 +434,14 @@ if ($save_on_server) {
/** @var Relation $relation */
$relation = $containerBuilder->get('relation');
// Fake loop just to allow skip of remain of this code by break, I'd really
// need exceptions here :-)
do {
try {
// Re - initialize
$dump_buffer = '';
$dump_buffer_len = 0;
// Add possibly some comments to export
if (! $export_plugin->exportHeader()) {
break;
throw new ExportException('Failure during header export.');
}
// Will we need relation & co. setup?
@ -591,10 +590,11 @@ do {
}
}
if (! $export_plugin->exportFooter()) {
break;
throw new ExportException('Failure during footer export.');
}
} while (false);
// End of fake loop
} catch (ExportException $e) {
null; // Avoid phpcs error...
}
if ($save_on_server && ! empty($message)) {
$export->showPage($db, $table, $export_type);