From b3b8a84783e8531c39272470f246f4be5611741c Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Fri, 1 Nov 2019 17:12:31 +0100 Subject: [PATCH] Replace fake loop by try/catch with exceptions Signed-off-by: Hugues Peccatte --- .../classes/Exceptions/ExportException.php | 21 +++++++++++++++++++ libraries/entry_points/export.php | 14 ++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 libraries/classes/Exceptions/ExportException.php diff --git a/libraries/classes/Exceptions/ExportException.php b/libraries/classes/Exceptions/ExportException.php new file mode 100644 index 0000000000..22aea3f5ee --- /dev/null +++ b/libraries/classes/Exceptions/ExportException.php @@ -0,0 +1,21 @@ +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);