diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 6ae427635e..07ed04013a 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -5839,9 +5839,6 @@
-
-
-
@@ -5878,9 +5875,6 @@
-
-
-
@@ -6066,9 +6060,6 @@
-
-
-
collation)]]>
selectedServer['port'])]]>
@@ -6437,10 +6428,6 @@
-
-
-
-
diff --git a/src/Controllers/Export/ExportController.php b/src/Controllers/Export/ExportController.php
index 630505228f..e43b570ea1 100644
--- a/src/Controllers/Export/ExportController.php
+++ b/src/Controllers/Export/ExportController.php
@@ -301,9 +301,7 @@ final readonly class ExportController implements InvocableController
}
// Add possibly some comments to export
- if (! $exportPlugin->exportHeader()) {
- throw new ExportException('Failure during header export.');
- }
+ $exportPlugin->exportHeader();
/**
* Builds the dump
@@ -351,7 +349,7 @@ final readonly class ExportController implements InvocableController
);
}
} elseif ($exportType === ExportType::Raw) {
- Export::exportRaw($exportPlugin, Current::$database, Current::$sqlQuery);
+ $exportPlugin->exportRawQuery(Current::$database, Current::$sqlQuery);
} else {
// We export just one table
@@ -389,9 +387,7 @@ final readonly class ExportController implements InvocableController
}
}
- if (! $exportPlugin->exportFooter()) {
- throw new ExportException('Failure during footer export.');
- }
+ $exportPlugin->exportFooter();
} catch (ExportException) {
// Ignore
}
diff --git a/src/Exceptions/InsufficientSpaceExportException.php b/src/Exceptions/InsufficientSpaceExportException.php
new file mode 100644
index 0000000000..8dc43095e8
--- /dev/null
+++ b/src/Exceptions/InsufficientSpaceExportException.php
@@ -0,0 +1,15 @@
+getName()]['alias'])
? $aliases[$db->getName()]['alias'] : '';
- if (! $exportPlugin->exportDBHeader($db->getName(), $dbAlias)) {
- return;
- }
+ $exportPlugin->exportDBHeader($db->getName(), $dbAlias);
- if (! $exportPlugin->exportDBCreate($db->getName(), $dbAlias)) {
- return;
- }
+ $exportPlugin->exportDBCreate($db->getName(), $dbAlias);
if ($separateFiles === SeparateFiles::Database) {
$this->outputHandler->saveObjectInBuffer('database', true);
@@ -331,20 +327,15 @@ class Export
// for a view, export a stand-in definition of the table
// to resolve view dependencies (only when it's a single-file export)
if ($isView) {
- if (
- $separateFiles === SeparateFiles::None
- && ! $exportPlugin->exportStructure($db->getName(), $table, 'stand_in', $aliases)
- ) {
- break;
+ if ($separateFiles === SeparateFiles::None) {
+ $exportPlugin->exportStructure($db->getName(), $table, 'stand_in', $aliases);
}
} else {
if ($this->exceedsMaxTableSize($db->getName(), $table)) {
continue;
}
- if (! $exportPlugin->exportStructure($db->getName(), $table, 'create_table', $aliases)) {
- break;
- }
+ $exportPlugin->exportStructure($db->getName(), $table, 'create_table', $aliases);
}
}
@@ -357,9 +348,7 @@ class Export
. ' FROM ' . Util::backquote($db->getName())
. '.' . Util::backquote($table);
- if (! $exportPlugin->exportData($db->getName(), $table, $localQuery, $aliases)) {
- break;
- }
+ $exportPlugin->exportData($db->getName(), $table, $localQuery, $aliases);
}
// this buffer was filled, we save it and go to the next one
@@ -373,9 +362,7 @@ class Export
continue;
}
- if (! $exportPlugin->exportStructure($db->getName(), $table, 'triggers', $aliases)) {
- break;
- }
+ $exportPlugin->exportStructure($db->getName(), $table, 'triggers', $aliases);
if ($separateFiles !== SeparateFiles::Database) {
continue;
@@ -390,9 +377,7 @@ class Export
continue;
}
- if (! $exportPlugin->exportStructure($db->getName(), $view, 'create_view', $aliases)) {
- break;
- }
+ $exportPlugin->exportStructure($db->getName(), $view, 'create_view', $aliases);
if ($separateFiles !== SeparateFiles::Database) {
continue;
@@ -401,9 +386,7 @@ class Export
$this->outputHandler->saveObjectInBuffer('view_' . $view);
}
- if (! $exportPlugin->exportDBFooter($db->getName())) {
- return;
- }
+ $exportPlugin->exportDBFooter($db->getName());
if ($separateFiles === SeparateFiles::Database) {
$this->outputHandler->saveObjectInBuffer('extra');
@@ -431,29 +414,6 @@ class Export
$this->outputHandler->saveObjectInBuffer('events');
}
- /**
- * Export a raw query
- *
- * @param ExportPlugin $exportPlugin the selected export plugin
- * @param string|null $db the database where the query is executed
- * @param string $sqlQuery the query to be executed
- */
- public static function exportRaw(
- ExportPlugin $exportPlugin,
- string|null $db,
- string $sqlQuery,
- ): void {
- if ($exportPlugin->exportRawQuery($db, $sqlQuery)) {
- return;
- }
-
- Current::$message = Message::error(
- // phpcs:disable Generic.Files.LineLength.TooLong
- /* l10n: A query written by the user is a "raw query" that could be using no tables or databases in particular */
- __('Exporting a raw query is not supported for this export method.'),
- );
- }
-
/**
* Export at the table level
*
@@ -478,9 +438,7 @@ class Export
): void {
$dbAlias = ! empty($aliases[$db]['alias'])
? $aliases[$db]['alias'] : '';
- if (! $exportPlugin->exportDBHeader($db, $dbAlias)) {
- return;
- }
+ $exportPlugin->exportDBHeader($db, $dbAlias);
if ($allrows === '0' && $limitTo > 0 && $limitFrom >= 0) {
$addQuery = ' LIMIT '
@@ -493,11 +451,9 @@ class Export
if ($exportPlugin->includeStructure()) {
$tableObject = new Table($table, $db, $this->dbi);
if ($tableObject->isView()) {
- if (! $exportPlugin->exportStructure($db, $table, 'create_view', $aliases)) {
- return;
- }
- } elseif (! $exportPlugin->exportStructure($db, $table, 'create_table', $aliases)) {
- return;
+ $exportPlugin->exportStructure($db, $table, 'create_view', $aliases);
+ } else {
+ $exportPlugin->exportStructure($db, $table, 'create_table', $aliases);
}
}
@@ -524,22 +480,16 @@ class Export
. '.' . Util::backquote($table) . $addQuery;
}
- if (! $exportPlugin->exportData($db, $table, $localQuery, $aliases)) {
- return;
- }
+ $exportPlugin->exportData($db, $table, $localQuery, $aliases);
}
// now export the triggers (needs to be done after the data because
// triggers can modify already imported tables)
if ($exportPlugin->includeStructure()) {
- if (! $exportPlugin->exportStructure($db, $table, 'triggers', $aliases)) {
- return;
- }
+ $exportPlugin->exportStructure($db, $table, 'triggers', $aliases);
}
- if (! $exportPlugin->exportDBFooter($db)) {
- return;
- }
+ $exportPlugin->exportDBFooter($db);
// Types of metadata to export.
// In the future these can be allowed to be selected by the user
@@ -621,7 +571,9 @@ class Export
$val1 = $colAs[0];
$val2 = $colAs[1];
// Use aliases2 alias if non empty
- $aliases[$dbName]['tables'][$tableName]['columns'][$col] = $val2 !== '' && $val2 !== null ? $val2 : $val1;
+ $aliases[$dbName]['tables'][$tableName]['columns'][$col] = $val2 !== '' && $val2 !== null
+ ? $val2
+ : $val1;
}
}
}
diff --git a/src/Export/OutputHandler.php b/src/Export/OutputHandler.php
index c6d2895ccf..e9dbfee172 100644
--- a/src/Export/OutputHandler.php
+++ b/src/Export/OutputHandler.php
@@ -7,6 +7,7 @@ namespace PhpMyAdmin\Export;
use PhpMyAdmin\Core;
use PhpMyAdmin\Current;
use PhpMyAdmin\Encoding;
+use PhpMyAdmin\Exceptions\InsufficientSpaceExportException;
use PhpMyAdmin\Message;
use PhpMyAdmin\MessageType;
use PhpMyAdmin\Util;
@@ -54,7 +55,8 @@ class OutputHandler
public int $memoryLimit = 0;
public bool $onFlyCompression = false;
- public function addLine(string $line): bool
+ /** @throws InsufficientSpaceExportException */
+ public function addLine(string $line): void
{
// Kanji encoding convert feature
if ($this->outputKanjiConversion) {
@@ -82,7 +84,7 @@ class OutputHandler
Current::$message = Message::error(__('Insufficient space to save the file %s.'));
Current::$message->addParam($this->saveFilename);
- return false;
+ throw new InsufficientSpaceExportException();
}
} else {
echo $this->dumpBuffer;
@@ -93,14 +95,14 @@ class OutputHandler
}
}
- return true;
+ return;
}
if (! self::$asFile) {
// We export as html - replace special chars
echo htmlspecialchars($line, ENT_COMPAT);
- return true;
+ return;
}
if ($this->outputCharsetConversion) {
@@ -113,14 +115,12 @@ class OutputHandler
Current::$message = Message::error(__('Insufficient space to save the file %s.'));
Current::$message->addParam($this->saveFilename);
- return false;
+ throw new InsufficientSpaceExportException();
}
} else {
// We export as file - output normally
echo $line;
}
-
- return true;
}
/**
diff --git a/src/Plugins/Export/ExportCodegen.php b/src/Plugins/Export/ExportCodegen.php
index 8ae0d7182a..c180f5d6b2 100644
--- a/src/Plugins/Export/ExportCodegen.php
+++ b/src/Plugins/Export/ExportCodegen.php
@@ -95,12 +95,14 @@ class ExportCodegen extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
- ): bool {
+ ): void {
if ($this->format === self::HANDLER_NHIBERNATE_XML) {
- return $this->outputHandler->addLine($this->handleNHibernateXMLBody($db, $table, $aliases));
+ $this->outputHandler->addLine($this->handleNHibernateXMLBody($db, $table, $aliases));
+
+ return;
}
- return $this->outputHandler->addLine($this->handleNHibernateCSBody($db, $table, $aliases));
+ $this->outputHandler->addLine($this->handleNHibernateCSBody($db, $table, $aliases));
}
/**
diff --git a/src/Plugins/Export/ExportCsv.php b/src/Plugins/Export/ExportCsv.php
index 6d03e05fb3..f0d67503f4 100644
--- a/src/Plugins/Export/ExportCsv.php
+++ b/src/Plugins/Export/ExportCsv.php
@@ -136,7 +136,7 @@ class ExportCsv extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
- ): bool {
+ ): void {
$dbi = DatabaseInterface::getInstance();
$result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED);
@@ -159,9 +159,7 @@ class ExportCsv extends ExportPlugin
}
$schemaInsert = implode($this->separator, $insertFields);
- if (! $this->outputHandler->addLine($schemaInsert . $this->terminated)) {
- return false;
- }
+ $this->outputHandler->addLine($schemaInsert . $this->terminated);
}
// Format the data
@@ -208,12 +206,8 @@ class ExportCsv extends ExportPlugin
}
$schemaInsert = implode($this->separator, $insertValues);
- if (! $this->outputHandler->addLine($schemaInsert . $this->terminated)) {
- return false;
- }
+ $this->outputHandler->addLine($schemaInsert . $this->terminated);
}
-
- return true;
}
/**
@@ -222,13 +216,13 @@ class ExportCsv extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
- public function exportRawQuery(string|null $db, string $sqlQuery): bool
+ public function exportRawQuery(string|null $db, string $sqlQuery): void
{
if ($db !== null) {
DatabaseInterface::getInstance()->selectDb($db);
}
- return $this->exportData($db ?? '', '', $sqlQuery);
+ $this->exportData($db ?? '', '', $sqlQuery);
}
/** @inheritDoc */
diff --git a/src/Plugins/Export/ExportExcel.php b/src/Plugins/Export/ExportExcel.php
index 9821527ca4..b1306428dd 100644
--- a/src/Plugins/Export/ExportExcel.php
+++ b/src/Plugins/Export/ExportExcel.php
@@ -132,7 +132,7 @@ class ExportExcel extends ExportPlugin
string $table,
string $sqlQuery,
array $aliases = [],
- ): bool {
+ ): void {
$dbi = DatabaseInterface::getInstance();
/**
* Gets the data from the database
@@ -155,9 +155,7 @@ class ExportExcel extends ExportPlugin
}
$schemaInsert = implode($this->separator, $insertFields);
- if (! $this->outputHandler->addLine($schemaInsert . $this->terminated)) {
- return false;
- }
+ $this->outputHandler->addLine($schemaInsert . $this->terminated);
}
// Format the data
@@ -206,12 +204,8 @@ class ExportExcel extends ExportPlugin
}
$schemaInsert = implode($this->separator, $insertValues);
- if (! $this->outputHandler->addLine($schemaInsert . $this->terminated)) {
- return false;
- }
+ $this->outputHandler->addLine($schemaInsert . $this->terminated);
}
-
- return true;
}
/**
@@ -220,13 +214,13 @@ class ExportExcel extends ExportPlugin
* @param string|null $db the database where the query is executed
* @param string $sqlQuery the rawquery to output
*/
- public function exportRawQuery(string|null $db, string $sqlQuery): bool
+ public function exportRawQuery(string|null $db, string $sqlQuery): void
{
if ($db !== null) {
DatabaseInterface::getInstance()->selectDb($db);
}
- return $this->exportData($db ?? '', '', $sqlQuery);
+ $this->exportData($db ?? '', '', $sqlQuery);
}
/** @inheritDoc */
diff --git a/src/Plugins/Export/ExportHtmlword.php b/src/Plugins/Export/ExportHtmlword.php
index bb90e40a71..7013732a4a 100644
--- a/src/Plugins/Export/ExportHtmlword.php
+++ b/src/Plugins/Export/ExportHtmlword.php
@@ -104,9 +104,9 @@ class ExportHtmlword extends ExportPlugin
/**
* Outputs export header
*/
- public function exportHeader(): bool
+ public function exportHeader(): void
{
- return $this->outputHandler->addLine(
+ $this->outputHandler->addLine(
'
@@ -125,9 +125,9 @@ class ExportHtmlword extends ExportPlugin
/**
* Outputs export footer
*/
- public function exportFooter(): bool
+ public function exportFooter(): void
{
- return $this->outputHandler->addLine('