From 51569eb6441780c7e5365e3158b70cd893522068 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 9 Jan 2026 16:08:05 +0000 Subject: [PATCH 1/3] Create InsufficientSpaceExportException Signed-off-by: Kamil Tekiela --- psalm-baseline.xml | 13 - src/Controllers/Export/ExportController.php | 8 +- .../InsufficientSpaceExportException.php | 15 ++ src/Export/Export.php | 69 ++--- src/Export/OutputHandler.php | 14 +- src/Plugins/Export/ExportCodegen.php | 8 +- src/Plugins/Export/ExportCsv.php | 16 +- src/Plugins/Export/ExportExcel.php | 16 +- src/Plugins/Export/ExportHtmlword.php | 46 ++-- src/Plugins/Export/ExportJson.php | 53 ++-- src/Plugins/Export/ExportLatex.php | 74 +++--- src/Plugins/Export/ExportMediawiki.php | 12 +- src/Plugins/Export/ExportOds.php | 16 +- src/Plugins/Export/ExportOdt.php | 24 +- src/Plugins/Export/ExportPdf.php | 16 +- src/Plugins/Export/ExportPhparray.php | 24 +- src/Plugins/Export/ExportSql.php | 236 +++++++----------- src/Plugins/Export/ExportTexytext.php | 38 ++- src/Plugins/Export/ExportXml.php | 113 ++++----- src/Plugins/Export/ExportYaml.php | 20 +- src/Plugins/ExportPlugin.php | 32 +-- .../unit/Plugins/Export/ExportCodegenTest.php | 20 +- tests/unit/Plugins/Export/ExportCsvTest.php | 29 +-- tests/unit/Plugins/Export/ExportExcelTest.php | 19 +- .../Plugins/Export/ExportHtmlwordTest.php | 32 +-- tests/unit/Plugins/Export/ExportJsonTest.php | 43 +--- tests/unit/Plugins/Export/ExportLatexTest.php | 43 ++-- .../Plugins/Export/ExportMediawikiTest.php | 35 +-- tests/unit/Plugins/Export/ExportOdsTest.php | 43 +--- tests/unit/Plugins/Export/ExportOdtTest.php | 52 ++-- tests/unit/Plugins/Export/ExportPdfTest.php | 27 +- .../Plugins/Export/ExportPhparrayTest.php | 39 +-- tests/unit/Plugins/Export/ExportSqlTest.php | 50 ++-- .../Plugins/Export/ExportTexytextTest.php | 40 ++- tests/unit/Plugins/Export/ExportXmlTest.php | 41 +-- tests/unit/Plugins/Export/ExportYamlTest.php | 31 +-- 36 files changed, 503 insertions(+), 904 deletions(-) create mode 100644 src/Exceptions/InsufficientSpaceExportException.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 33d87ad891..f318f46d2b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -5887,9 +5887,6 @@ - - - @@ -5926,9 +5923,6 @@ - - - @@ -6114,9 +6108,6 @@ - - - collation)]]> selectedServer['port'])]]> @@ -6485,10 +6476,6 @@ - - - - diff --git a/src/Controllers/Export/ExportController.php b/src/Controllers/Export/ExportController.php index 630505228f..86e23c32e7 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 @@ -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'); @@ -443,15 +426,7 @@ class Export 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.'), - ); + $exportPlugin->exportRawQuery($db, $sqlQuery); } /** @@ -478,9 +453,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 +466,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 +495,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 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(''); + $this->outputHandler->addLine(''); } /** @@ -136,13 +136,13 @@ class ExportHtmlword extends ExportPlugin * @param string $db Database name * @param string $dbAlias Aliases of db */ - public function exportDBHeader(string $db, string $dbAlias = ''): bool + public function exportDBHeader(string $db, string $dbAlias = ''): void { if ($dbAlias === '') { $dbAlias = $db; } - return $this->outputHandler->addLine( + $this->outputHandler->addLine( '

' . __('Database') . ' ' . htmlspecialchars($dbAlias) . '

', ); } @@ -160,22 +160,16 @@ class ExportHtmlword extends ExportPlugin string $table, string $sqlQuery, array $aliases = [], - ): bool { + ): void { $tableAlias = $this->getTableAlias($aliases, $db, $table); - if ( - ! $this->outputHandler->addLine( - '

' - . __('Dumping data for table') . ' ' . htmlspecialchars($tableAlias) - . '

', - ) - ) { - return false; - } + $this->outputHandler->addLine( + '

' + . __('Dumping data for table') . ' ' . htmlspecialchars($tableAlias) + . '

', + ); - if (! $this->outputHandler->addLine('')) { - return false; - } + $this->outputHandler->addLine('
'); $dbi = DatabaseInterface::getInstance(); /** @@ -195,9 +189,7 @@ class ExportHtmlword extends ExportPlugin } $schemaInsert .= ''; - if (! $this->outputHandler->addLine($schemaInsert)) { - return false; - } + $this->outputHandler->addLine($schemaInsert); } // Format the data @@ -210,12 +202,10 @@ class ExportHtmlword extends ExportPlugin } $schemaInsert .= ''; - if (! $this->outputHandler->addLine($schemaInsert)) { - return false; - } + $this->outputHandler->addLine($schemaInsert); } - return $this->outputHandler->addLine('
'); + $this->outputHandler->addLine(''); } /** @@ -441,7 +431,7 @@ class ExportHtmlword extends ExportPlugin * @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in' * @param mixed[] $aliases Aliases of db/table/columns */ - public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool + public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void { $tableAlias = $this->getTableAlias($aliases, $db, $table); @@ -480,7 +470,7 @@ class ExportHtmlword extends ExportPlugin $dump .= $this->getTableDefStandIn($db, $table, $aliases); } - return $this->outputHandler->addLine($dump); + $this->outputHandler->addLine($dump); } /** diff --git a/src/Plugins/Export/ExportJson.php b/src/Plugins/Export/ExportJson.php index 06ef02a770..9542541566 100644 --- a/src/Plugins/Export/ExportJson.php +++ b/src/Plugins/Export/ExportJson.php @@ -9,6 +9,7 @@ namespace PhpMyAdmin\Plugins\Export; use PhpMyAdmin\Dbal\ConnectionType; use PhpMyAdmin\Dbal\DatabaseInterface; +use PhpMyAdmin\Exceptions\ExportException; use PhpMyAdmin\Export\StructureOrData; use PhpMyAdmin\FieldMetadata; use PhpMyAdmin\Http\ServerRequest; @@ -105,7 +106,7 @@ class ExportJson extends ExportPlugin /** * Outputs export header */ - public function exportHeader(): bool + public function exportHeader(): void { $data = $this->encode([ 'type' => 'header', @@ -113,18 +114,18 @@ class ExportJson extends ExportPlugin 'comment' => 'Export to JSON plugin for phpMyAdmin', ]); if ($data === false) { - return false; + throw new ExportException('Failure during header export.'); } - return $this->outputHandler->addLine('[' . "\n" . $data . ',' . "\n"); + $this->outputHandler->addLine('[' . "\n" . $data . ',' . "\n"); } /** * Outputs export footer */ - public function exportFooter(): bool + public function exportFooter(): void { - return $this->outputHandler->addLine(']' . "\n"); + $this->outputHandler->addLine(']' . "\n"); } /** @@ -133,7 +134,7 @@ class ExportJson extends ExportPlugin * @param string $db Database name * @param string $dbAlias Aliases of db */ - public function exportDBHeader(string $db, string $dbAlias = ''): bool + public function exportDBHeader(string $db, string $dbAlias = ''): void { if ($dbAlias === '') { $dbAlias = $db; @@ -141,10 +142,10 @@ class ExportJson extends ExportPlugin $data = $this->encode(['type' => 'database', 'name' => $dbAlias]); if ($data === false) { - return false; + throw new ExportException('Failure during header export.'); } - return $this->outputHandler->addLine($data . ',' . "\n"); + $this->outputHandler->addLine($data . ',' . "\n"); } /** @@ -160,14 +161,12 @@ class ExportJson extends ExportPlugin string $table, string $sqlQuery, array $aliases = [], - ): bool { + ): void { $dbAlias = $this->getDbAlias($aliases, $db); $tableAlias = $this->getTableAlias($aliases, $db, $table); if (! $this->first) { - if (! $this->outputHandler->addLine(',')) { - return false; - } + $this->outputHandler->addLine(','); } else { $this->first = false; } @@ -179,10 +178,10 @@ class ExportJson extends ExportPlugin 'data' => '@@DATA@@', ]); if ($buffer === false) { - return false; + throw new ExportException('Failure during data export.'); } - return $this->doExportForQuery(DatabaseInterface::getInstance(), $sqlQuery, $buffer, $aliases, $db, $table); + $this->doExportForQuery(DatabaseInterface::getInstance(), $sqlQuery, $buffer, $aliases, $db, $table); } /** @@ -198,19 +197,17 @@ class ExportJson extends ExportPlugin * } * >|null $aliases */ - protected function doExportForQuery( + private function doExportForQuery( DatabaseInterface $dbi, string $sqlQuery, string $buffer, array|null $aliases, string|null $db, string|null $table, - ): bool { + ): void { [$header, $footer] = explode('"@@DATA@@"', $buffer); - if (! $this->outputHandler->addLine($header . "\n" . '[' . "\n")) { - return false; - } + $this->outputHandler->addLine($header . "\n" . '[' . "\n"); $result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED); $columnsCnt = $result->numFields(); @@ -234,9 +231,7 @@ class ExportJson extends ExportPlugin // Output table name as comment if this is the first record of the table if ($recordCnt > 1) { - if (! $this->outputHandler->addLine(',' . "\n")) { - return false; - } + $this->outputHandler->addLine(',' . "\n"); } $data = []; @@ -269,15 +264,13 @@ class ExportJson extends ExportPlugin $encodedData = $this->encode($data); if ($encodedData === '' || $encodedData === false) { - return false; + throw new ExportException('Failure during data export.'); } - if (! $this->outputHandler->addLine($encodedData)) { - return false; - } + $this->outputHandler->addLine($encodedData); } - return $this->outputHandler->addLine("\n" . ']' . "\n" . $footer . "\n"); + $this->outputHandler->addLine("\n" . ']' . "\n" . $footer . "\n"); } /** @@ -286,11 +279,11 @@ class ExportJson 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 { $buffer = $this->encode(['type' => 'raw', 'data' => '@@DATA@@']); if ($buffer === false) { - return false; + throw new ExportException('Failure during data export.'); } $dbi = DatabaseInterface::getInstance(); @@ -298,7 +291,7 @@ class ExportJson extends ExportPlugin $dbi->selectDb($db); } - return $this->doExportForQuery($dbi, $sqlQuery, $buffer, null, $db, null); + $this->doExportForQuery($dbi, $sqlQuery, $buffer, null, $db, null); } /** @inheritDoc */ diff --git a/src/Plugins/Export/ExportLatex.php b/src/Plugins/Export/ExportLatex.php index eec57fc40f..fc795b310d 100644 --- a/src/Plugins/Export/ExportLatex.php +++ b/src/Plugins/Export/ExportLatex.php @@ -215,7 +215,7 @@ class ExportLatex extends ExportPlugin /** * Outputs export header */ - public function exportHeader(): bool + public function exportHeader(): void { $config = Config::getInstance(); $head = '% phpMyAdmin LaTeX Dump' . "\n" @@ -233,7 +233,7 @@ class ExportLatex extends ExportPlugin . '% ' . __('Server version:') . ' ' . DatabaseInterface::getInstance()->getVersionString() . "\n" . '% ' . __('PHP Version:') . ' ' . PHP_VERSION . "\n"; - return $this->outputHandler->addLine($head); + $this->outputHandler->addLine($head); } /** @@ -242,7 +242,7 @@ class ExportLatex extends ExportPlugin * @param string $db Database name * @param string $dbAlias Aliases of db */ - public function exportDBHeader(string $db, string $dbAlias = ''): bool + public function exportDBHeader(string $db, string $dbAlias = ''): void { if ($dbAlias === '') { $dbAlias = $db; @@ -252,7 +252,7 @@ class ExportLatex extends ExportPlugin . '% ' . __('Database:') . ' \'' . $dbAlias . '\'' . "\n" . '% ' . "\n"; - return $this->outputHandler->addLine($head); + $this->outputHandler->addLine($head); } /** @@ -268,7 +268,7 @@ class ExportLatex extends ExportPlugin string $table, string $sqlQuery, array $aliases = [], - ): bool { + ): void { $dbAlias = $this->getDbAlias($aliases, $db); $tableAlias = $this->getTableAlias($aliases, $db, $table); @@ -309,9 +309,7 @@ class ExportLatex extends ExportPlugin . '} \\\\'; } - if (! $this->outputHandler->addLine($buffer)) { - return false; - } + $this->outputHandler->addLine($buffer); // show column names if ($this->columns) { @@ -322,31 +320,23 @@ class ExportLatex extends ExportPlugin } $buffer = mb_substr($buffer, 0, -2) . '\\\\ \\hline \hline '; - if (! $this->outputHandler->addLine($buffer . ' \\endfirsthead ' . "\n")) { - return false; - } + $this->outputHandler->addLine($buffer . ' \\endfirsthead ' . "\n"); if ($this->caption) { - if ( - ! $this->outputHandler->addLine( - '\\caption{' - . Util::expandUserString( - $this->dataContinuedCaption, - [static::class, 'texEscape'], - ['table' => $tableAlias, 'database' => $dbAlias], - ) - . '} \\\\ ', + $this->outputHandler->addLine( + '\\caption{' + . Util::expandUserString( + $this->dataContinuedCaption, + [static::class, 'texEscape'], + ['table' => $tableAlias, 'database' => $dbAlias], ) - ) { - return false; - } + . '} \\\\ ', + ); } - if (! $this->outputHandler->addLine($buffer . '\\endhead \\endfoot' . "\n")) { - return false; - } - } elseif (! $this->outputHandler->addLine('\\\\ \hline')) { - return false; + $this->outputHandler->addLine($buffer . '\\endhead \\endfoot' . "\n"); + } else { + $this->outputHandler->addLine('\\\\ \hline'); } // print the whole table @@ -370,14 +360,12 @@ class ExportLatex extends ExportPlugin } $buffer .= ' \\\\ \\hline ' . "\n"; - if (! $this->outputHandler->addLine($buffer)) { - return false; - } + $this->outputHandler->addLine($buffer); } $buffer = ' \\end{longtable}' . "\n"; - return $this->outputHandler->addLine($buffer); + $this->outputHandler->addLine($buffer); } /** @@ -386,13 +374,13 @@ class ExportLatex 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); } /** @@ -403,7 +391,7 @@ class ExportLatex extends ExportPlugin * @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in' * @param mixed[] $aliases Aliases of db/table/columns */ - public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool + public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void { $dbAlias = $this->getDbAlias($aliases, $db); $tableAlias = $this->getTableAlias($aliases, $db, $table); @@ -412,7 +400,7 @@ class ExportLatex extends ExportPlugin /* We do not export triggers */ if ($exportMode === 'triggers') { - return true; + return; } /** @@ -443,9 +431,7 @@ class ExportLatex extends ExportPlugin */ $buffer = "\n" . '%' . "\n" . '% ' . __('Structure:') . ' ' . $tableAlias . "\n" . '%' . "\n" . ' \\begin{longtable}{'; - if (! $this->outputHandler->addLine($buffer)) { - return false; - } + $this->outputHandler->addLine($buffer); $alignment = '|l|c|c|c|'; if ($this->doRelation && $foreigners !== null && ! $foreigners->isEmpty()) { @@ -513,9 +499,7 @@ class ExportLatex extends ExportPlugin $buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . "\n"; - if (! $this->outputHandler->addLine($buffer)) { - return false; - } + $this->outputHandler->addLine($buffer); $fields = $dbi->getColumns($db, $table); foreach ($fields as $row) { @@ -565,14 +549,12 @@ class ExportLatex extends ExportPlugin $buffer = str_replace("\000", ' & ', $localBuffer); $buffer .= ' \\\\ \\hline ' . "\n"; - if (! $this->outputHandler->addLine($buffer)) { - return false; - } + $this->outputHandler->addLine($buffer); } $buffer = ' \\end{longtable}' . "\n"; - return $this->outputHandler->addLine($buffer); + $this->outputHandler->addLine($buffer); } /** diff --git a/src/Plugins/Export/ExportMediawiki.php b/src/Plugins/Export/ExportMediawiki.php index 6bc5abb086..0f8ca661fc 100644 --- a/src/Plugins/Export/ExportMediawiki.php +++ b/src/Plugins/Export/ExportMediawiki.php @@ -102,7 +102,7 @@ class ExportMediawiki extends ExportPlugin * * @infection-ignore-all */ - public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool + public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void { $tableAlias = $this->getTableAlias($aliases, $db, $table); @@ -166,7 +166,7 @@ class ExportMediawiki extends ExportPlugin $output .= '|}' . str_repeat($this->exportCRLF(), 2); } - return $this->outputHandler->addLine($output); + $this->outputHandler->addLine($output); } /** @@ -182,7 +182,7 @@ class ExportMediawiki extends ExportPlugin string $table, string $sqlQuery, array $aliases = [], - ): bool { + ): void { $tableAlias = $this->getTableAlias($aliases, $db, $table); // Print data comment @@ -240,7 +240,7 @@ class ExportMediawiki extends ExportPlugin // End table construction $output .= '|}' . str_repeat($this->exportCRLF(), 2); - return $this->outputHandler->addLine($output); + $this->outputHandler->addLine($output); } /** @@ -249,13 +249,13 @@ class ExportMediawiki 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); } /** diff --git a/src/Plugins/Export/ExportOds.php b/src/Plugins/Export/ExportOds.php index b90bb831a4..0d4922d260 100644 --- a/src/Plugins/Export/ExportOds.php +++ b/src/Plugins/Export/ExportOds.php @@ -84,7 +84,7 @@ class ExportOds extends ExportPlugin /** * Outputs export header */ - public function exportHeader(): bool + public function exportHeader(): void { $this->buffer .= '' . '' . '' . ''; - - return true; } /** * Outputs export footer */ - public function exportFooter(): bool + public function exportFooter(): void { $this->buffer .= ''; - return $this->outputHandler->addLine( + $this->outputHandler->addLine( OpenDocument::create('application/vnd.oasis.opendocument.spreadsheet', $this->buffer), ); } @@ -160,7 +158,7 @@ class ExportOds extends ExportPlugin string $table, string $sqlQuery, array $aliases = [], - ): bool { + ): void { $tableAlias = $this->getTableAlias($aliases, $db, $table); $dbi = DatabaseInterface::getInstance(); // Gets the data from the database @@ -256,8 +254,6 @@ class ExportOds extends ExportPlugin } $this->buffer .= ''; - - return true; } /** @@ -266,13 +262,13 @@ class ExportOds 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/ExportOdt.php b/src/Plugins/Export/ExportOdt.php index 392e39efd7..6893e493cf 100644 --- a/src/Plugins/Export/ExportOdt.php +++ b/src/Plugins/Export/ExportOdt.php @@ -145,25 +145,23 @@ class ExportOdt extends ExportPlugin /** * Outputs export header */ - public function exportHeader(): bool + public function exportHeader(): void { $this->buffer .= '' . '' . '' . ''; - - return true; } /** * Outputs export footer */ - public function exportFooter(): bool + public function exportFooter(): void { $this->buffer .= ''; - return $this->outputHandler->addLine(OpenDocument::create( + $this->outputHandler->addLine(OpenDocument::create( 'application/vnd.oasis.opendocument.text', $this->buffer, )); @@ -175,7 +173,7 @@ class ExportOdt extends ExportPlugin * @param string $db Database name * @param string $dbAlias Aliases of db */ - public function exportDBHeader(string $db, string $dbAlias = ''): bool + public function exportDBHeader(string $db, string $dbAlias = ''): void { if ($dbAlias === '') { $dbAlias = $db; @@ -185,8 +183,6 @@ class ExportOdt extends ExportPlugin . ' text:is-list-header="true">' . __('Database') . ' ' . htmlspecialchars($dbAlias) . ''; - - return true; } /** @@ -202,7 +198,7 @@ class ExportOdt extends ExportPlugin string $table, string $sqlQuery, array $aliases = [], - ): bool { + ): void { $tableAlias = $this->getTableAlias($aliases, $db, $table); $dbi = DatabaseInterface::getInstance(); // Gets the data from the database @@ -280,8 +276,6 @@ class ExportOdt extends ExportPlugin } $this->buffer .= ''; - - return true; } /** @@ -290,13 +284,13 @@ class ExportOdt 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); } /** @@ -559,7 +553,7 @@ class ExportOdt extends ExportPlugin * @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in' * @param mixed[] $aliases Aliases of db/table/columns */ - public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool + public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void { $tableAlias = $this->getTableAlias($aliases, $db, $table); switch ($exportMode) { @@ -600,8 +594,6 @@ class ExportOdt extends ExportPlugin // export a stand-in definition to resolve view dependencies $this->getTableDefStandIn($db, $table, $aliases); } - - return true; } /** diff --git a/src/Plugins/Export/ExportPdf.php b/src/Plugins/Export/ExportPdf.php index a834652401..3a670904af 100644 --- a/src/Plugins/Export/ExportPdf.php +++ b/src/Plugins/Export/ExportPdf.php @@ -101,10 +101,10 @@ class ExportPdf extends ExportPlugin /** * Outputs export footer */ - public function exportFooter(): bool + public function exportFooter(): void { // instead of $pdf->Output(): - return $this->outputHandler->addLine($this->pdf->getPDFData()); + $this->outputHandler->addLine($this->pdf->getPDFData()); } /** @@ -120,7 +120,7 @@ class ExportPdf extends ExportPlugin string $table, string $sqlQuery, array $aliases = [], - ): bool { + ): void { $dbAlias = $this->getDbAlias($aliases, $db); $tableAlias = $this->getTableAlias($aliases, $db, $table); $this->pdf->setCurrentDb($db); @@ -130,8 +130,6 @@ class ExportPdf extends ExportPlugin $this->pdf->setAliases($aliases); $this->pdf->setPurpose(__('Dumping data')); $this->pdf->mysqlReport($sqlQuery); - - return true; } /** @@ -140,7 +138,7 @@ class ExportPdf 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 { $this->pdf->setDbAlias('----'); $this->pdf->setTableAlias('----'); @@ -152,8 +150,6 @@ class ExportPdf extends ExportPlugin } $this->pdf->mysqlReport($sqlQuery); - - return true; } /** @@ -164,7 +160,7 @@ class ExportPdf extends ExportPlugin * @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in' * @param mixed[] $aliases aliases for db/table/columns */ - public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool + public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void { $purpose = ''; $dbAlias = $this->getDbAlias($aliases, $db); @@ -197,8 +193,6 @@ class ExportPdf extends ExportPlugin 'triggers' => $this->pdf->getTriggers($db, $table), default => true, }; - - return true; } public static function isAvailable(): bool diff --git a/src/Plugins/Export/ExportPhparray.php b/src/Plugins/Export/ExportPhparray.php index 255b435b01..10a42349fa 100644 --- a/src/Plugins/Export/ExportPhparray.php +++ b/src/Plugins/Export/ExportPhparray.php @@ -76,7 +76,7 @@ class ExportPhparray extends ExportPlugin /** * Outputs export header */ - public function exportHeader(): bool + public function exportHeader(): void { $this->outputHandler->addLine( 'commentString(Util::backquote($dbAlias)) . "\n" . ' */' . "\n", ); - - return true; } /** @@ -123,7 +119,7 @@ class ExportPhparray extends ExportPlugin string $table, string $sqlQuery, array $aliases = [], - ): bool { + ): void { $dbAlias = $this->getDbAlias($aliases, $db); $tableAlias = $this->getTableAlias($aliases, $db, $table); @@ -160,9 +156,7 @@ class ExportPhparray extends ExportPlugin . $this->commentString(Util::backquote($dbAlias)) . '.' . $this->commentString(Util::backquote($tableAlias)) . ' */' . "\n"; $buffer .= '$' . $tableFixed . ' = array('; - if (! $this->outputHandler->addLine($buffer)) { - return false; - } + $this->outputHandler->addLine($buffer); // Reset the buffer $buffer = ''; @@ -183,9 +177,7 @@ class ExportPhparray extends ExportPlugin } $buffer .= ')'; - if (! $this->outputHandler->addLine($buffer)) { - return false; - } + $this->outputHandler->addLine($buffer); // Reset the buffer $buffer = ''; @@ -193,7 +185,7 @@ class ExportPhparray extends ExportPlugin $buffer .= "\n" . ');' . "\n"; - return $this->outputHandler->addLine($buffer); + $this->outputHandler->addLine($buffer); } /** @@ -202,13 +194,13 @@ class ExportPhparray 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/ExportSql.php b/src/Plugins/Export/ExportSql.php index b4dd988f8a..d7a8ffa88d 100644 --- a/src/Plugins/Export/ExportSql.php +++ b/src/Plugins/Export/ExportSql.php @@ -611,10 +611,10 @@ class ExportSql extends ExportPlugin * @param string $db Database * @param mixed[] $aliases Aliases of db/table/columns */ - public function exportRoutines(string $db, array $aliases = []): bool + public function exportRoutines(string $db, array $aliases = []): void { if (! $this->hasCreateProcedureFunction) { - return true; + return; } $text = ''; @@ -653,11 +653,11 @@ class ExportSql extends ExportPlugin $text .= 'DELIMITER ;' . "\n"; } - if ($text !== '') { - return $this->outputHandler->addLine($text); + if ($text === '') { + return; } - return false; + $this->outputHandler->addLine($text); } /** @@ -708,7 +708,7 @@ class ExportSql extends ExportPlugin /** * Outputs export footer */ - public function exportFooter(): bool + public function exportFooter(): void { $foot = ''; @@ -737,14 +737,14 @@ class ExportSql extends ExportPlugin DatabaseInterface::getInstance()->query('SET time_zone = "' . self::$oldTimezone . '"'); } - return $this->outputHandler->addLine($foot); + $this->outputHandler->addLine($foot); } /** * Outputs export header. It is the first method to be called, so all * the required variables are initialized here. */ - public function exportHeader(): bool + public function exportHeader(): void { $dbi = DatabaseInterface::getInstance(); @@ -833,7 +833,7 @@ class ExportSql extends ExportPlugin $this->sentCharset = true; } - return $this->outputHandler->addLine($head); + $this->outputHandler->addLine($head); } /** @@ -842,26 +842,22 @@ class ExportSql extends ExportPlugin * @param string $db Database name * @param string $dbAlias Aliases of db */ - public function exportDBCreate(string $db, string $dbAlias = ''): bool + public function exportDBCreate(string $db, string $dbAlias = ''): void { if ($dbAlias === '') { $dbAlias = $db; } if ($this->includeStructure() && $this->dropDatabase) { - if ( - ! $this->outputHandler->addLine( - 'DROP DATABASE IF EXISTS ' - . Util::backquoteCompat($dbAlias, $this->compatibility, $this->useSqlBackquotes) - . ';' . "\n", - ) - ) { - return false; - } + $this->outputHandler->addLine( + 'DROP DATABASE IF EXISTS ' + . Util::backquoteCompat($dbAlias, $this->compatibility, $this->useSqlBackquotes) + . ';' . "\n", + ); } if (ExportPlugin::$exportType === ExportType::Database && ! $this->createDatabase) { - return true; + return; } $createQuery = 'CREATE DATABASE IF NOT EXISTS ' @@ -880,11 +876,9 @@ class ExportSql extends ExportPlugin } $createQuery .= ';' . "\n"; - if (! $this->outputHandler->addLine($createQuery)) { - return false; - } + $this->outputHandler->addLine($createQuery); - return $this->exportUseStatement($dbAlias, $this->compatibility); + $this->exportUseStatement($dbAlias, $this->compatibility); } /** @@ -893,17 +887,19 @@ class ExportSql extends ExportPlugin * @param string $db db to use * @param string $compat sql compatibility */ - private function exportUseStatement(string $db, string $compat): bool + private function exportUseStatement(string $db, string $compat): void { if ($compat === 'NONE') { - return $this->outputHandler->addLine( + $this->outputHandler->addLine( 'USE ' . Util::backquoteCompat($db, $compat, $this->useSqlBackquotes) . ';' . "\n", ); + + return; } - return $this->outputHandler->addLine('USE ' . $db . ';' . "\n"); + $this->outputHandler->addLine('USE ' . $db . ';' . "\n"); } /** @@ -912,7 +908,7 @@ class ExportSql extends ExportPlugin * @param string $db Database name * @param string $dbAlias Alias of db */ - public function exportDBHeader(string $db, string $dbAlias = ''): bool + public function exportDBHeader(string $db, string $dbAlias = ''): void { if ($dbAlias === '') { $dbAlias = $db; @@ -929,7 +925,7 @@ class ExportSql extends ExportPlugin ) . $this->exportComment(); - return $this->outputHandler->addLine($head); + $this->outputHandler->addLine($head); } /** @@ -937,35 +933,33 @@ class ExportSql extends ExportPlugin * * @param string $db Database name */ - public function exportDBFooter(string $db): bool + public function exportDBFooter(string $db): void { - $result = true; - //add indexes to the sql dump file if ($this->sqlIndexes !== null) { - $result = $this->outputHandler->addLine($this->sqlIndexes); + $this->outputHandler->addLine($this->sqlIndexes); $this->sqlIndexes = null; } //add auto increments to the sql dump file if ($this->sqlAutoIncrements !== null) { - $result = $this->outputHandler->addLine($this->sqlAutoIncrements); + $this->outputHandler->addLine($this->sqlAutoIncrements); $this->sqlAutoIncrements = null; } //add views to the sql dump file if ($this->sqlViews !== '') { - $result = $this->outputHandler->addLine($this->sqlViews); + $this->outputHandler->addLine($this->sqlViews); $this->sqlViews = ''; } //add constraints to the sql dump file - if ($this->sqlConstraints !== null) { - $result = $this->outputHandler->addLine($this->sqlConstraints); - $this->sqlConstraints = null; + if ($this->sqlConstraints === null) { + return; } - return $result; + $this->outputHandler->addLine($this->sqlConstraints); + $this->sqlConstraints = null; } /** @@ -973,10 +967,10 @@ class ExportSql extends ExportPlugin * * @param string $db Database */ - public function exportEvents(string $db): bool + public function exportEvents(string $db): void { if (! $this->hasCreateProcedureFunction) { - return true; + return; } $text = ''; @@ -1022,11 +1016,11 @@ class ExportSql extends ExportPlugin $text .= 'DELIMITER ;' . "\n"; } - if ($text !== '') { - return $this->outputHandler->addLine($text); + if ($text === '') { + return; } - return false; + $this->outputHandler->addLine($text); } /** @@ -1040,14 +1034,14 @@ class ExportSql extends ExportPlugin string $db, string|array $tables, array $metadataTypes, - ): bool { + ): void { if (! $this->hasMetadata) { - return true; + return; } $relationParameters = $this->relation->getRelationParameters(); if ($relationParameters->db === null) { - return true; + return; } $comment = $this->possibleCRLF() @@ -1055,27 +1049,23 @@ class ExportSql extends ExportPlugin . $this->exportComment() . $this->exportComment(__('Metadata')) . $this->exportComment(); - if (! $this->outputHandler->addLine($comment)) { - return false; - } + $this->outputHandler->addLine($comment); - if (! $this->exportUseStatement((string) $relationParameters->db, $this->compatibility)) { - return false; - } + $this->exportUseStatement((string) $relationParameters->db, $this->compatibility); if (is_array($tables)) { - $isSuccessful = true; - // export metadata for each table foreach ($tables as $table) { - $isSuccessful = $this->exportConfigurationMetadata($db, $table, $metadataTypes) && $isSuccessful; + $this->exportConfigurationMetadata($db, $table, $metadataTypes); } // export metadata for the database - return $this->exportConfigurationMetadata($db, null, $metadataTypes) && $isSuccessful; + $this->exportConfigurationMetadata($db, null, $metadataTypes); + + return; } // export metadata for single table - return $this->exportConfigurationMetadata($db, $tables, $metadataTypes); + $this->exportConfigurationMetadata($db, $tables, $metadataTypes); } /** @@ -1089,7 +1079,7 @@ class ExportSql extends ExportPlugin string $db, string|null $table, array $metadataTypes, - ): bool { + ): void { $relationParameters = $this->relation->getRelationParameters(); $relationParams = $relationParameters->toArray(); @@ -1131,9 +1121,7 @@ class ExportSql extends ExportPlugin $comment .= $this->exportComment(); - if (! $this->outputHandler->addLine($comment)) { - return false; - } + $this->outputHandler->addLine($comment); foreach ($types as $type => $dbNameColumn) { if (! in_array($type, $metadataTypes, true) || ! isset($relationParams[$type])) { @@ -1162,23 +1150,17 @@ class ExportSql extends ExportPlugin . ' WHERE `db_name` = ' . $dbi->quoteString($db) . ' AND `page_nr` = ' . (int) $page; - if ( - ! $this->exportData( - $relationParameters->pdfFeature->database->getName(), - $relationParameters->pdfFeature->pdfPages->getName(), - $sqlQueryRow, - $aliases, - ) - ) { - return false; - } + $this->exportData( + $relationParameters->pdfFeature->database->getName(), + $relationParameters->pdfFeature->pdfPages->getName(), + $sqlQueryRow, + $aliases, + ); $lastPage = "\n" . 'SET @LAST_PAGE = LAST_INSERT_ID();' . "\n"; - if (! $this->outputHandler->addLine($lastPage)) { - return false; - } + $this->outputHandler->addLine($lastPage); $sqlQueryCoords = 'SELECT `db_name`, `table_name`, ' . "'@LAST_PAGE' AS `pdf_page_number`, `x`, `y` FROM " @@ -1187,18 +1169,12 @@ class ExportSql extends ExportPlugin . " WHERE `pdf_page_number` = '" . $page . "'"; self::$exportingMetadata = true; - if ( - ! $this->exportData( - $relationParameters->pdfFeature->database->getName(), - $relationParameters->pdfFeature->tableCoords->getName(), - $sqlQueryCoords, - $aliases, - ) - ) { - self::$exportingMetadata = false; - - return false; - } + $this->exportData( + $relationParameters->pdfFeature->database->getName(), + $relationParameters->pdfFeature->tableCoords->getName(), + $sqlQueryCoords, + $aliases, + ); self::$exportingMetadata = false; } @@ -1226,19 +1202,8 @@ class ExportSql extends ExportPlugin $sqlQuery .= ' AND `table_name` = ' . $dbi->quoteString($table); } - if ( - ! $this->exportData( - (string) $relationParameters->db, - (string) $relationParams[$type], - $sqlQuery, - $aliases, - ) - ) { - return false; - } + $this->exportData((string) $relationParameters->db, (string) $relationParams[$type], $sqlQuery, $aliases); } - - return true; } /** @@ -1845,13 +1810,13 @@ class ExportSql 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); } /** @@ -1862,7 +1827,7 @@ class ExportSql extends ExportPlugin * @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in' * @param mixed[] $aliases Aliases of db/table/columns */ - public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool + public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void { $tableAlias = $this->getTableAlias($aliases, $db, $table); $formattedTableName = Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes); @@ -1874,7 +1839,7 @@ class ExportSql extends ExportPlugin switch ($exportMode) { case 'create_table': if (! $this->hasCreateTable) { - return true; // User requested no table structure, so the job has been successfully completed + return; } $dump .= $this->exportComment( @@ -1886,7 +1851,7 @@ class ExportSql extends ExportPlugin break; case 'triggers': if (! $this->hasCreateTrigger) { - return true; // User requested no triggers, so the job has been successfully completed + return; } $dump = ''; @@ -1939,7 +1904,7 @@ class ExportSql extends ExportPlugin break; case 'create_view': if (! $this->hasCreateView) { - return true; // No view to export, so the job has been successfully completed + return; } if (! $this->viewsAsTables) { @@ -1983,7 +1948,7 @@ class ExportSql extends ExportPlugin break; case 'stand_in': if (! $this->hasCreateView) { - return true; // No view to export, so the job has been successfully completed + return; } $dump .= $this->exportComment( @@ -2001,7 +1966,7 @@ class ExportSql extends ExportPlugin // but not in the case of export $this->sqlConstraintsQuery = ''; - return $this->outputHandler->addLine($dump); + $this->outputHandler->addLine($dump); } /** @@ -2017,11 +1982,11 @@ class ExportSql extends ExportPlugin string $table, string $sqlQuery, array $aliases = [], - ): bool { + ): void { $dbi = DatabaseInterface::getInstance(); // Do not export data for merge tables if ($dbi->getTable($db, $table)->isMerge()) { - return true; + return; } $tableAlias = $this->getTableAlias($aliases, $db, $table); @@ -2038,7 +2003,9 @@ class ExportSql extends ExportPlugin . $this->exportComment() . $this->possibleCRLF(); - return $this->outputHandler->addLine($head); + $this->outputHandler->addLine($head); + + return; } $result = $dbi->tryQuery($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED); @@ -2052,7 +2019,7 @@ class ExportSql extends ExportPlugin } if ($result === false) { - return true; + return; } $fieldsCnt = $result->numFields(); @@ -2146,22 +2113,16 @@ class ExportSql extends ExportPlugin ) . $this->exportComment() . "\n"; - if (! $this->outputHandler->addLine($head)) { - return false; - } + $this->outputHandler->addLine($head); } // We need to SET IDENTITY_INSERT ON for MSSQL if ($currentRow === 0 && $this->compatibility === 'MSSQL') { - if ( - ! $this->outputHandler->addLine( - 'SET IDENTITY_INSERT ' - . Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes) - . ' ON ;' . "\n", - ) - ) { - return false; - } + $this->outputHandler->addLine( + 'SET IDENTITY_INSERT ' + . Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes) + . ' ON ;' . "\n", + ); } $currentRow++; @@ -2233,9 +2194,7 @@ class ExportSql extends ExportPlugin $insertLine = '(' . implode(', ', $values) . ')'; $insertLineSize = mb_strlen($insertLine); if ($this->maxQuerySize > 0 && $querySize + $insertLineSize > $this->maxQuerySize) { - if (! $this->outputHandler->addLine(';' . "\n")) { - return false; - } + $this->outputHandler->addLine(';' . "\n"); $querySize = 0; $currentRow = 1; @@ -2249,30 +2208,23 @@ class ExportSql extends ExportPlugin $insertLine = $schemaInsert . '(' . implode(', ', $values) . ')'; } - if (! $this->outputHandler->addLine(($currentRow === 1 ? '' : $separator . "\n") . $insertLine)) { - return false; - } + $this->outputHandler->addLine(($currentRow === 1 ? '' : $separator . "\n") . $insertLine); } if ($currentRow > 0) { - if (! $this->outputHandler->addLine(';' . "\n")) { - return false; - } + $this->outputHandler->addLine(';' . "\n"); } // We need to SET IDENTITY_INSERT OFF for MSSQL - if ($this->compatibility === 'MSSQL' && $currentRow > 0) { - $outputSucceeded = $this->outputHandler->addLine( - "\n" . 'SET IDENTITY_INSERT ' - . Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes) - . ' OFF;' . "\n", - ); - if (! $outputSucceeded) { - return false; - } + if ($this->compatibility !== 'MSSQL' || $currentRow <= 0) { + return; } - return true; + $this->outputHandler->addLine( + "\n" . 'SET IDENTITY_INSERT ' + . Util::backquoteCompat($tableAlias, $this->compatibility, $this->useSqlBackquotes) + . ' OFF;' . "\n", + ); } /** diff --git a/src/Plugins/Export/ExportTexytext.php b/src/Plugins/Export/ExportTexytext.php index d12d24162b..5ebf146d48 100644 --- a/src/Plugins/Export/ExportTexytext.php +++ b/src/Plugins/Export/ExportTexytext.php @@ -105,13 +105,13 @@ class ExportTexytext extends ExportPlugin * @param string $db Database name * @param string $dbAlias Alias of db */ - public function exportDBHeader(string $db, string $dbAlias = ''): bool + public function exportDBHeader(string $db, string $dbAlias = ''): void { if ($dbAlias === '') { $dbAlias = $db; } - return $this->outputHandler->addLine( + $this->outputHandler->addLine( '===' . __('Database') . ' ' . $dbAlias . "\n\n", ); } @@ -129,18 +129,14 @@ class ExportTexytext extends ExportPlugin string $table, string $sqlQuery, array $aliases = [], - ): bool { + ): void { $tableAlias = $this->getTableAlias($aliases, $db, $table); - if ( - ! $this->outputHandler->addLine( - $tableAlias !== '' - ? '== ' . __('Dumping data for table') . ' ' . $tableAlias . "\n\n" - : '==' . __('Dumping data for query result') . "\n\n", - ) - ) { - return false; - } + $this->outputHandler->addLine( + $tableAlias !== '' + ? '== ' . __('Dumping data for table') . ' ' . $tableAlias . "\n\n" + : '==' . __('Dumping data for query result') . "\n\n", + ); $dbi = DatabaseInterface::getInstance(); /** @@ -158,9 +154,7 @@ class ExportTexytext extends ExportPlugin } $textOutput .= "\n|------\n"; - if (! $this->outputHandler->addLine($textOutput)) { - return false; - } + $this->outputHandler->addLine($textOutput); } // Format the data @@ -184,12 +178,8 @@ class ExportTexytext extends ExportPlugin } $textOutput .= "\n"; - if (! $this->outputHandler->addLine($textOutput)) { - return false; - } + $this->outputHandler->addLine($textOutput); } - - return true; } /** @@ -198,13 +188,13 @@ class ExportTexytext 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); } /** @@ -399,7 +389,7 @@ class ExportTexytext extends ExportPlugin * @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in' * @param mixed[] $aliases Aliases of db/table/columns */ - public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool + public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void { $tableAlias = $this->getTableAlias($aliases, $db, $table); $dump = ''; @@ -429,7 +419,7 @@ class ExportTexytext extends ExportPlugin $dump .= $this->getTableDefStandIn($db, $table, $aliases); } - return $this->outputHandler->addLine($dump); + $this->outputHandler->addLine($dump); } /** diff --git a/src/Plugins/Export/ExportXml.php b/src/Plugins/Export/ExportXml.php index 69271e5596..4ce945bf06 100644 --- a/src/Plugins/Export/ExportXml.php +++ b/src/Plugins/Export/ExportXml.php @@ -177,7 +177,7 @@ class ExportXml extends ExportPlugin * Outputs export header. It is the first method to be called, so all * the required variables are initialized here. */ - public function exportHeader(): bool + public function exportHeader(): void { $exportStruct = $this->exportFunctions || $this->exportProcedures @@ -248,8 +248,7 @@ class ExportXml extends ExportPlugin $tbl = (string) $result[$table][1]; - $isView = $dbi->getTable(Current::$database, $table) - ->isView(); + $isView = $dbi->getTable(Current::$database, $table)->isView(); $type = $isView ? 'view' : 'table'; @@ -327,17 +326,17 @@ class ExportXml extends ExportPlugin } } - return $this->outputHandler->addLine($head); + $this->outputHandler->addLine($head); } /** * Outputs export footer */ - public function exportFooter(): bool + public function exportFooter(): void { $foot = ''; - return $this->outputHandler->addLine($foot); + $this->outputHandler->addLine($foot); } /** @@ -346,23 +345,23 @@ class ExportXml extends ExportPlugin * @param string $db Database name * @param string $dbAlias Aliases of db */ - public function exportDBHeader(string $db, string $dbAlias = ''): bool + public function exportDBHeader(string $db, string $dbAlias = ''): void { if ($dbAlias === '') { $dbAlias = $db; } - if ($this->exportContents) { - $head = ' ' . "\n" . ' ' . "\n"; - - return $this->outputHandler->addLine($head); + if (! $this->exportContents) { + return; } - return true; + $head = ' ' . "\n" . ' ' . "\n"; + + $this->outputHandler->addLine($head); } /** @@ -370,13 +369,13 @@ class ExportXml extends ExportPlugin * * @param string $db Database name */ - public function exportDBFooter(string $db): bool + public function exportDBFooter(string $db): void { - if ($this->exportContents) { - return $this->outputHandler->addLine(' ' . "\n"); + if (! $this->exportContents) { + return; } - return true; + $this->outputHandler->addLine(' ' . "\n"); } /** @@ -392,53 +391,49 @@ class ExportXml extends ExportPlugin string $table, string $sqlQuery, array $aliases = [], - ): bool { + ): void { $dbi = DatabaseInterface::getInstance(); // Do not export data for merge tables if ($dbi->getTable($db, $table)->isMerge()) { - return true; + return; } $tableAlias = $this->getTableAlias($aliases, $db, $table); - if ($this->exportContents) { - $result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED); - - $columnsCnt = $result->numFields(); - $columns = $result->getFieldNames(); - - $buffer = ' ' . "\n"; - if (! $this->outputHandler->addLine($buffer)) { - return false; - } - - while ($record = $result->fetchRow()) { - $buffer = ' ' . "\n"; - for ($i = 0; $i < $columnsCnt; $i++) { - $colAs = $this->getColumnAlias($aliases, $db, $table, $columns[$i]); - - // If a cell is NULL, still export it to preserve - // the XML structure - if (! isset($record[$i])) { - $record[$i] = 'NULL'; - } - - $buffer .= ' ' - . htmlspecialchars($record[$i]) - . '' . "\n"; - } - - $buffer .= '
' . "\n"; - - if (! $this->outputHandler->addLine($buffer)) { - return false; - } - } + if (! $this->exportContents) { + return; } - return true; + $result = $dbi->query($sqlQuery, ConnectionType::User, DatabaseInterface::QUERY_UNBUFFERED); + + $columnsCnt = $result->numFields(); + $columns = $result->getFieldNames(); + + $buffer = ' ' . "\n"; + $this->outputHandler->addLine($buffer); + + while ($record = $result->fetchRow()) { + $buffer = ' ' . "\n"; + for ($i = 0; $i < $columnsCnt; $i++) { + $colAs = $this->getColumnAlias($aliases, $db, $table, $columns[$i]); + + // If a cell is NULL, still export it to preserve + // the XML structure + if (! isset($record[$i])) { + $record[$i] = 'NULL'; + } + + $buffer .= ' ' + . htmlspecialchars($record[$i]) + . '' . "\n"; + } + + $buffer .= '
' . "\n"; + + $this->outputHandler->addLine($buffer); + } } /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ diff --git a/src/Plugins/Export/ExportYaml.php b/src/Plugins/Export/ExportYaml.php index fd46f87d6a..65a22f085b 100644 --- a/src/Plugins/Export/ExportYaml.php +++ b/src/Plugins/Export/ExportYaml.php @@ -65,21 +65,17 @@ class ExportYaml extends ExportPlugin /** * Outputs export header */ - public function exportHeader(): bool + public function exportHeader(): void { $this->outputHandler->addLine('%YAML 1.1' . "\n" . '---' . "\n"); - - return true; } /** * Outputs export footer */ - public function exportFooter(): bool + public function exportFooter(): void { $this->outputHandler->addLine('...' . "\n"); - - return true; } /** @@ -95,7 +91,7 @@ class ExportYaml extends ExportPlugin string $table, string $sqlQuery, array $aliases = [], - ): bool { + ): void { $dbAlias = $this->getDbAlias($aliases, $db); $tableAlias = $this->getTableAlias($aliases, $db, $table); $dbi = DatabaseInterface::getInstance(); @@ -148,12 +144,8 @@ class ExportYaml extends ExportPlugin $buffer .= ' ' . $columns[$i] . ': "' . $record[$i] . '"' . "\n"; } - if (! $this->outputHandler->addLine($buffer)) { - return false; - } + $this->outputHandler->addLine($buffer); } - - return true; } /** @@ -162,13 +154,13 @@ class ExportYaml 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/ExportPlugin.php b/src/Plugins/ExportPlugin.php index 92684577a8..1fef0cd47b 100644 --- a/src/Plugins/ExportPlugin.php +++ b/src/Plugins/ExportPlugin.php @@ -47,17 +47,15 @@ abstract class ExportPlugin implements Plugin /** * Outputs export header */ - public function exportHeader(): bool + public function exportHeader(): void { - return true; } /** * Outputs export footer */ - public function exportFooter(): bool + public function exportFooter(): void { - return true; } /** @@ -66,9 +64,8 @@ abstract class ExportPlugin implements Plugin * @param string $db Database name * @param string $dbAlias Aliases of db */ - public function exportDBHeader(string $db, string $dbAlias = ''): bool + public function exportDBHeader(string $db, string $dbAlias = ''): void { - return true; } /** @@ -76,9 +73,8 @@ abstract class ExportPlugin implements Plugin * * @param string $db Database name */ - public function exportDBFooter(string $db): bool + public function exportDBFooter(string $db): void { - return true; } /** @@ -87,9 +83,8 @@ abstract class ExportPlugin implements Plugin * @param string $db Database name * @param string $dbAlias Aliases of db */ - public function exportDBCreate(string $db, string $dbAlias = ''): bool + public function exportDBCreate(string $db, string $dbAlias = ''): void { - return true; } /** @@ -105,7 +100,7 @@ abstract class ExportPlugin implements Plugin string $table, string $sqlQuery, array $aliases = [], - ): bool; + ): void; /** * The following methods are used in /export or in /database/operations, @@ -118,9 +113,8 @@ abstract class ExportPlugin implements Plugin * @param string $db Database * @param mixed[] $aliases Aliases of db/table/columns */ - public function exportRoutines(string $db, array $aliases = []): bool + public function exportRoutines(string $db, array $aliases = []): void { - return true; } /** @@ -128,9 +122,8 @@ abstract class ExportPlugin implements Plugin * * @param string $db Database */ - public function exportEvents(string $db): bool + public function exportEvents(string $db): void { - return true; } /** @@ -139,9 +132,8 @@ abstract class ExportPlugin implements Plugin * @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 { - return false; } /** @@ -152,9 +144,8 @@ abstract class ExportPlugin implements Plugin * @param string $exportMode 'create_table', 'triggers', 'create_view', 'stand_in' * @param mixed[] $aliases Aliases of db/table/columns */ - public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): bool + public function exportStructure(string $db, string $table, string $exportMode, array $aliases = []): void { - return true; } /** @@ -168,8 +159,7 @@ abstract class ExportPlugin implements Plugin string $db, string|array $tables, array $metadataTypes, - ): bool { - return true; + ): void { } /** diff --git a/tests/unit/Plugins/Export/ExportCodegenTest.php b/tests/unit/Plugins/Export/ExportCodegenTest.php index d1f06bf011..766c2998bf 100644 --- a/tests/unit/Plugins/Export/ExportCodegenTest.php +++ b/tests/unit/Plugins/Export/ExportCodegenTest.php @@ -136,30 +136,26 @@ class ExportCodegenTest extends AbstractTestCase public function testExportHeader(): void { - self::assertTrue( - $this->object->exportHeader(), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportHeader(); } public function testExportFooter(): void { - self::assertTrue( - $this->object->exportFooter(), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportFooter(); } public function testExportDBHeader(): void { - self::assertTrue( - $this->object->exportDBHeader('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBHeader('testDB'); } public function testExportDBFooter(): void { - self::assertTrue( - $this->object->exportDBFooter('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBFooter('testDB'); } public function testExportData(): void diff --git a/tests/unit/Plugins/Export/ExportCsvTest.php b/tests/unit/Plugins/Export/ExportCsvTest.php index 807200195d..f51b9a72e9 100644 --- a/tests/unit/Plugins/Export/ExportCsvTest.php +++ b/tests/unit/Plugins/Export/ExportCsvTest.php @@ -228,27 +228,32 @@ class ExportCsvTest extends AbstractTestCase public function testExportHeader(): void { // case 1 - self::assertTrue($this->object->exportHeader()); + $this->expectNotToPerformAssertions(); + $this->object->exportHeader(); } public function testExportFooter(): void { - self::assertTrue($this->object->exportFooter()); + $this->expectNotToPerformAssertions(); + $this->object->exportFooter(); } public function testExportDBHeader(): void { - self::assertTrue($this->object->exportDBHeader('testDB')); + $this->expectNotToPerformAssertions(); + $this->object->exportDBHeader('testDB'); } public function testExportDBFooter(): void { - self::assertTrue($this->object->exportDBFooter('testDB')); + $this->expectNotToPerformAssertions(); + $this->object->exportDBFooter('testDB'); } public function testExportDBCreate(): void { - self::assertTrue($this->object->exportDBCreate('testDB')); + $this->expectNotToPerformAssertions(); + $this->object->exportDBCreate('testDB'); } public function testExportData(): void @@ -263,11 +268,7 @@ class ExportCsvTest extends AbstractTestCase $this->object->exportHeader(); ob_start(); - self::assertTrue($this->object->exportData( - 'test_db', - 'test_table', - 'SELECT * FROM `test_db`.`test_table_csv_export`;', - )); + $this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table_csv_export`;'); $result = ob_get_clean(); self::assertSame( @@ -284,11 +285,11 @@ class ExportCsvTest extends AbstractTestCase $this->object->exportHeader(); ob_start(); - self::assertTrue($this->object->exportData( + $this->object->exportData( 'test_db', 'test_table_csv_export', 'SELECT * FROM `test_db`.`test_table_csv_export`;', - )); + ); $result = ob_get_clean(); self::assertSame( @@ -310,11 +311,11 @@ class ExportCsvTest extends AbstractTestCase $this->object->exportHeader(); ob_start(); - self::assertTrue($this->object->exportData( + $this->object->exportData( 'test_db', 'test_table_csv_export', 'SELECT * FROM `test_db`.`test_table_csv_export`;', - )); + ); $result = ob_get_clean(); self::assertSame( diff --git a/tests/unit/Plugins/Export/ExportExcelTest.php b/tests/unit/Plugins/Export/ExportExcelTest.php index 2024943c8f..1b004c3e54 100644 --- a/tests/unit/Plugins/Export/ExportExcelTest.php +++ b/tests/unit/Plugins/Export/ExportExcelTest.php @@ -188,9 +188,8 @@ class ExportExcelTest extends AbstractTestCase public function testExportHeader(): void { // case 1 - self::assertTrue( - $this->object->exportHeader(), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportHeader(); // case 2 $request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/') @@ -198,9 +197,7 @@ class ExportExcelTest extends AbstractTestCase $this->object->setExportOptions($request, []); - self::assertTrue( - $this->object->exportHeader(), - ); + $this->object->exportHeader(); // case 3 $request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/') @@ -208,9 +205,7 @@ class ExportExcelTest extends AbstractTestCase $this->object->setExportOptions($request, []); - self::assertTrue( - $this->object->exportHeader(), - ); + $this->object->exportHeader(); } public function testExportData(): void @@ -224,11 +219,7 @@ class ExportExcelTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue($this->object->exportData( - 'test_db', - 'test_table', - 'SELECT * FROM `test_db`.`test_table`;', - )); + $this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;'); $result = ob_get_clean(); self::assertSame( diff --git a/tests/unit/Plugins/Export/ExportHtmlwordTest.php b/tests/unit/Plugins/Export/ExportHtmlwordTest.php index 529ddebfa7..4714b4f8b2 100644 --- a/tests/unit/Plugins/Export/ExportHtmlwordTest.php +++ b/tests/unit/Plugins/Export/ExportHtmlwordTest.php @@ -253,9 +253,7 @@ class ExportHtmlwordTest extends AbstractTestCase public function testExportFooter(): void { ob_start(); - self::assertTrue( - $this->object->exportFooter(), - ); + $this->object->exportFooter(); $result = ob_get_clean(); self::assertSame('', $result); @@ -264,9 +262,7 @@ class ExportHtmlwordTest extends AbstractTestCase public function testExportDBHeader(): void { ob_start(); - self::assertTrue( - $this->object->exportDBHeader('d"b'), - ); + $this->object->exportDBHeader('d"b'); $result = ob_get_clean(); self::assertSame('

Database d"b

', $result); @@ -274,16 +270,14 @@ class ExportHtmlwordTest extends AbstractTestCase public function testExportDBFooter(): void { - self::assertTrue( - $this->object->exportDBFooter('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBFooter('testDB'); } public function testExportDBCreate(): void { - self::assertTrue( - $this->object->exportDBCreate('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBCreate('testDB'); } public function testExportData(): void @@ -297,11 +291,7 @@ class ExportHtmlwordTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue($this->object->exportData( - 'test_db', - 'test_table', - 'SELECT * FROM `test_db`.`test_table`;', - )); + $this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;'); $result = ob_get_clean(); self::assertSame( @@ -589,7 +579,7 @@ class ExportHtmlwordTest extends AbstractTestCase { ob_start(); $this->dummyDbi->addSelectDb('test_db'); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_table')); + $this->object->exportStructure('test_db', 'test_table', 'create_table'); $this->dummyDbi->assertAllSelectsConsumed(); $result = ob_get_clean(); @@ -608,7 +598,7 @@ class ExportHtmlwordTest extends AbstractTestCase ); ob_start(); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'triggers')); + $this->object->exportStructure('test_db', 'test_table', 'triggers'); $result = ob_get_clean(); self::assertSame( @@ -623,7 +613,7 @@ class ExportHtmlwordTest extends AbstractTestCase ob_start(); $this->dummyDbi->addSelectDb('test_db'); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_view')); + $this->object->exportStructure('test_db', 'test_table', 'create_view'); $this->dummyDbi->assertAllSelectsConsumed(); $result = ob_get_clean(); @@ -642,7 +632,7 @@ class ExportHtmlwordTest extends AbstractTestCase ); ob_start(); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'stand_in')); + $this->object->exportStructure('test_db', 'test_table', 'stand_in'); $result = ob_get_clean(); self::assertSame( diff --git a/tests/unit/Plugins/Export/ExportJsonTest.php b/tests/unit/Plugins/Export/ExportJsonTest.php index 5184e6911c..47868f41d7 100644 --- a/tests/unit/Plugins/Export/ExportJsonTest.php +++ b/tests/unit/Plugins/Export/ExportJsonTest.php @@ -120,41 +120,33 @@ class ExportJsonTest extends AbstractTestCase . "\n", ); - self::assertTrue( - $this->object->exportHeader(), - ); + $this->object->exportHeader(); } public function testExportFooter(): void { $this->expectOutputString(']' . "\n"); - self::assertTrue( - $this->object->exportFooter(), - ); + $this->object->exportFooter(); } public function testExportDBHeader(): void { $this->expectOutputString('{"type":"database","name":"testDB"},' . "\n"); - self::assertTrue( - $this->object->exportDBHeader('testDB'), - ); + $this->object->exportDBHeader('testDB'); } public function testExportDBFooter(): void { - self::assertTrue( - $this->object->exportDBFooter('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBFooter('testDB'); } public function testExportDBCreate(): void { - self::assertTrue( - $this->object->exportDBCreate('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBCreate('testDB'); } public function testExportData(): void @@ -169,11 +161,7 @@ class ExportJsonTest extends AbstractTestCase . '}' . "\n", ); - self::assertTrue($this->object->exportData( - 'test_db', - 'test_table', - 'SELECT * FROM `test_db`.`test_table`;', - )); + $this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;'); } public function testExportComplexData(): void @@ -190,13 +178,7 @@ class ExportJsonTest extends AbstractTestCase . "]\n}\n", ); - self::assertTrue( - $this->object->exportData( - 'test_db', - 'test_table_complex', - 'SELECT * FROM `test_db`.`test_table_complex`;', - ), - ); + $this->object->exportData('test_db', 'test_table_complex', 'SELECT * FROM `test_db`.`test_table_complex`;'); } public function testExportRawComplexData(): void @@ -212,11 +194,6 @@ class ExportJsonTest extends AbstractTestCase . "]\n}\n", ); - self::assertTrue( - $this->object->exportRawQuery( - null, - 'SELECT * FROM `test_db`.`test_table_complex`;', - ), - ); + $this->object->exportRawQuery(null, 'SELECT * FROM `test_db`.`test_table_complex`;'); } } diff --git a/tests/unit/Plugins/Export/ExportLatexTest.php b/tests/unit/Plugins/Export/ExportLatexTest.php index 6656d2f341..83d1f7d54e 100644 --- a/tests/unit/Plugins/Export/ExportLatexTest.php +++ b/tests/unit/Plugins/Export/ExportLatexTest.php @@ -432,9 +432,7 @@ class ExportLatexTest extends AbstractTestCase $config->selectedServer['host'] = 'localhost'; ob_start(); - self::assertTrue( - $this->object->exportHeader(), - ); + $this->object->exportHeader(); $result = ob_get_clean(); self::assertIsString($result); @@ -444,32 +442,27 @@ class ExportLatexTest extends AbstractTestCase public function testExportFooter(): void { - self::assertTrue( - $this->object->exportFooter(), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportFooter(); } public function testExportDBHeader(): void { $this->expectOutputString("% \n% Database: 'testDB'\n% \n"); - self::assertTrue( - $this->object->exportDBHeader('testDB'), - ); + $this->object->exportDBHeader('testDB'); } public function testExportDBFooter(): void { - self::assertTrue( - $this->object->exportDBFooter('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBFooter('testDB'); } public function testExportDBCreate(): void { - self::assertTrue( - $this->object->exportDBCreate('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBCreate('testDB'); } public function testExportData(): void @@ -491,11 +484,7 @@ class ExportLatexTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue($this->object->exportData( - 'test_db', - 'test_table', - 'SELECT * FROM `test_db`.`test_table`;', - )); + $this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;'); $result = ob_get_clean(); self::assertSame( @@ -530,11 +519,7 @@ class ExportLatexTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue($this->object->exportData( - 'test_db', - 'test_table', - 'SELECT * FROM `test_db`.`test_table`;', - )); + $this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;'); $result = ob_get_clean(); self::assertIsString($result); @@ -619,7 +604,7 @@ class ExportLatexTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue($this->object->exportStructure('database', '', 'test')); + $this->object->exportStructure('database', '', 'test'); $result = ob_get_clean(); //echo $result; die; @@ -699,7 +684,7 @@ class ExportLatexTest extends AbstractTestCase (new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters); ob_start(); - self::assertTrue($this->object->exportStructure('database', '', 'test')); + $this->object->exportStructure('database', '', 'test'); $result = ob_get_clean(); self::assertIsString($result); @@ -753,7 +738,7 @@ class ExportLatexTest extends AbstractTestCase (new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters); ob_start(); - self::assertTrue($this->object->exportStructure('database', '', 'test')); + $this->object->exportStructure('database', '', 'test'); $result = ob_get_clean(); self::assertIsString($result); @@ -763,7 +748,7 @@ class ExportLatexTest extends AbstractTestCase self::assertStringContainsString('caption{latexcontinued}', $result); // case 4 - self::assertTrue($this->object->exportStructure('database', '', 'triggers')); + $this->object->exportStructure('database', '', 'triggers'); } public function testTexEscape(): void diff --git a/tests/unit/Plugins/Export/ExportMediawikiTest.php b/tests/unit/Plugins/Export/ExportMediawikiTest.php index bec7303ca9..f0e8f92d48 100644 --- a/tests/unit/Plugins/Export/ExportMediawikiTest.php +++ b/tests/unit/Plugins/Export/ExportMediawikiTest.php @@ -179,37 +179,32 @@ class ExportMediawikiTest extends AbstractTestCase public function testExportHeader(): void { - self::assertTrue( - $this->object->exportHeader(), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportHeader(); } public function testExportFooter(): void { - self::assertTrue( - $this->object->exportFooter(), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportFooter(); } public function testExportDBHeader(): void { - self::assertTrue( - $this->object->exportDBHeader('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBHeader('testDB'); } public function testExportDBFooter(): void { - self::assertTrue( - $this->object->exportDBFooter('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBFooter('testDB'); } public function testExportDBCreate(): void { - self::assertTrue( - $this->object->exportDBCreate('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBCreate('testDB'); } /** @@ -239,7 +234,7 @@ class ExportMediawikiTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue($this->object->exportStructure('db', 'table', 'create_table')); + $this->object->exportStructure('db', 'table', 'create_table'); $result = ob_get_clean(); self::assertSame( @@ -282,13 +277,7 @@ class ExportMediawikiTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue( - $this->object->exportData( - 'test_db', - 'test_table', - 'SELECT * FROM `test_db`.`test_table`;', - ), - ); + $this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;'); $result = ob_get_clean(); self::assertSame( diff --git a/tests/unit/Plugins/Export/ExportOdsTest.php b/tests/unit/Plugins/Export/ExportOdsTest.php index f22639b495..7be0c4e131 100644 --- a/tests/unit/Plugins/Export/ExportOdsTest.php +++ b/tests/unit/Plugins/Export/ExportOdsTest.php @@ -166,7 +166,7 @@ class ExportOdsTest extends AbstractTestCase public function testExportHeader(): void { $this->object->buffer = ''; - self::assertTrue($this->object->exportHeader()); + $this->object->exportHeader(); self::assertStringStartsWith( 'object->buffer, @@ -176,7 +176,7 @@ class ExportOdsTest extends AbstractTestCase public function testExportFooter(): void { $this->object->buffer = 'header'; - self::assertTrue($this->object->exportFooter()); + $this->object->exportFooter(); $output = $this->getActualOutputForAssertion(); self::assertMatchesRegularExpression('/^504b.*636f6e74656e742e786d6c/', bin2hex($output)); self::assertStringContainsString('header', $this->object->buffer); @@ -187,23 +187,20 @@ class ExportOdsTest extends AbstractTestCase public function testExportDBHeader(): void { - self::assertTrue( - $this->object->exportDBHeader('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBHeader('testDB'); } public function testExportDBFooter(): void { - self::assertTrue( - $this->object->exportDBFooter('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBFooter('testDB'); } public function testExportDBCreate(): void { - self::assertTrue( - $this->object->exportDBCreate('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBCreate('testDB'); } public function testExportData(): void @@ -256,13 +253,7 @@ class ExportOdsTest extends AbstractTestCase $this->object->setExportOptions($request, []); - self::assertTrue( - $this->object->exportData( - 'db', - 'table', - 'SELECT', - ), - ); + $this->object->exportData('db', 'table', 'SELECT'); self::assertSame( 'object->setExportOptions($request, []); - self::assertTrue( - $this->object->exportData( - 'db', - 'table', - 'SELECT', - ), - ); + $this->object->exportData('db', 'table', 'SELECT'); self::assertSame( 'object->buffer = ''; - self::assertTrue( - $this->object->exportData( - 'db', - 'table', - 'SELECT', - ), - ); + $this->object->exportData('db', 'table', 'SELECT'); self::assertSame( '', diff --git a/tests/unit/Plugins/Export/ExportOdtTest.php b/tests/unit/Plugins/Export/ExportOdtTest.php index 76adf29f23..262cf97169 100644 --- a/tests/unit/Plugins/Export/ExportOdtTest.php +++ b/tests/unit/Plugins/Export/ExportOdtTest.php @@ -301,9 +301,7 @@ class ExportOdtTest extends AbstractTestCase public function testExportHeader(): void { - self::assertTrue( - $this->object->exportHeader(), - ); + $this->object->exportHeader(); self::assertStringContainsString('object->buffer); self::assertStringContainsString('office:version', $this->object->buffer); @@ -312,7 +310,7 @@ class ExportOdtTest extends AbstractTestCase public function testExportFooter(): void { $this->object->buffer = 'header'; - self::assertTrue($this->object->exportFooter()); + $this->object->exportFooter(); $output = $this->getActualOutputForAssertion(); self::assertMatchesRegularExpression('/^504b.*636f6e74656e742e786d6c/', bin2hex($output)); self::assertStringContainsString('header', $this->object->buffer); @@ -326,9 +324,7 @@ class ExportOdtTest extends AbstractTestCase { $this->object->buffer = 'header'; - self::assertTrue( - $this->object->exportDBHeader('d&b'), - ); + $this->object->exportDBHeader('d&b'); self::assertStringContainsString('header', $this->object->buffer); @@ -337,16 +333,14 @@ class ExportOdtTest extends AbstractTestCase public function testExportDBFooter(): void { - self::assertTrue( - $this->object->exportDBFooter('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBFooter('testDB'); } public function testExportDBCreate(): void { - self::assertTrue( - $this->object->exportDBCreate('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBCreate('testDB'); } public function testExportData(): void @@ -392,13 +386,7 @@ class ExportOdtTest extends AbstractTestCase $this->object->setExportOptions($request, []); - self::assertTrue( - $this->object->exportData( - 'db', - 'taobject->exportData('db', 'taobject->setExportOptions($request, []); - self::assertTrue( - $this->object->exportData( - 'db', - 'table', - 'SELECT', - ), - ); + $this->object->exportData('db', 'table', 'SELECT'); self::assertSame( 'object->buffer = ''; - self::assertTrue( - $this->object->exportData( - 'db', - 'table', - 'SELECT', - ), - ); + $this->object->exportData('db', 'table', 'SELECT'); self::assertSame( 'dummyDbi->addSelectDb('test_db'); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_table')); + $this->object->exportStructure('test_db', 'test_table', 'create_table'); $this->dummyDbi->assertAllSelectsConsumed(); self::assertSame( @@ -775,7 +751,7 @@ class ExportOdtTest extends AbstractTestCase // case 2 $this->object->buffer = ''; - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'triggers')); + $this->object->exportStructure('test_db', 'test_table', 'triggers'); self::assertSame( '' @@ -798,7 +774,7 @@ class ExportOdtTest extends AbstractTestCase $this->object->buffer = ''; $this->dummyDbi->addSelectDb('test_db'); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_view')); + $this->object->exportStructure('test_db', 'test_table', 'create_view'); $this->dummyDbi->assertAllSelectsConsumed(); self::assertSame( @@ -831,7 +807,7 @@ class ExportOdtTest extends AbstractTestCase // case 4 $this->dummyDbi->addSelectDb('test_db'); $this->object->buffer = ''; - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'stand_in')); + $this->object->exportStructure('test_db', 'test_table', 'stand_in'); $this->dummyDbi->assertAllSelectsConsumed(); self::assertSame( diff --git a/tests/unit/Plugins/Export/ExportPdfTest.php b/tests/unit/Plugins/Export/ExportPdfTest.php index 9efbdf47de..1889c0de8e 100644 --- a/tests/unit/Plugins/Export/ExportPdfTest.php +++ b/tests/unit/Plugins/Export/ExportPdfTest.php @@ -175,30 +175,25 @@ class ExportPdfTest extends AbstractTestCase $attrPdf = new ReflectionProperty(ExportPdf::class, 'pdf'); $attrPdf->setValue($this->object, $pdf); - self::assertTrue( - $this->object->exportFooter(), - ); + $this->object->exportFooter(); } public function testExportDBHeader(): void { - self::assertTrue( - $this->object->exportDBHeader('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBHeader('testDB'); } public function testExportDBFooter(): void { - self::assertTrue( - $this->object->exportDBFooter('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBFooter('testDB'); } public function testExportDBCreate(): void { - self::assertTrue( - $this->object->exportDBCreate('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBCreate('testDB'); } public function testExportData(): void @@ -214,12 +209,6 @@ class ExportPdfTest extends AbstractTestCase $attrPdf = new ReflectionProperty(ExportPdf::class, 'pdf'); $attrPdf->setValue($this->object, $pdf); - self::assertTrue( - $this->object->exportData( - 'db', - 'table', - 'SELECT', - ), - ); + $this->object->exportData('db', 'table', 'SELECT'); } } diff --git a/tests/unit/Plugins/Export/ExportPhparrayTest.php b/tests/unit/Plugins/Export/ExportPhparrayTest.php index 671854ad49..561255d761 100644 --- a/tests/unit/Plugins/Export/ExportPhparrayTest.php +++ b/tests/unit/Plugins/Export/ExportPhparrayTest.php @@ -115,9 +115,7 @@ class ExportPhparrayTest extends AbstractTestCase public function testExportHeader(): void { ob_start(); - self::assertTrue( - $this->object->exportHeader(), - ); + $this->object->exportHeader(); $result = ob_get_clean(); self::assertIsString($result); @@ -127,17 +125,14 @@ class ExportPhparrayTest extends AbstractTestCase public function testExportFooter(): void { - self::assertTrue( - $this->object->exportFooter(), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportFooter(); } public function testExportDBHeader(): void { ob_start(); - self::assertTrue( - $this->object->exportDBHeader('db'), - ); + $this->object->exportDBHeader('db'); $result = ob_get_clean(); self::assertIsString($result); @@ -147,28 +142,20 @@ class ExportPhparrayTest extends AbstractTestCase public function testExportDBFooter(): void { - self::assertTrue( - $this->object->exportDBFooter('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBFooter('testDB'); } public function testExportDBCreate(): void { - self::assertTrue( - $this->object->exportDBCreate('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBCreate('testDB'); } public function testExportData(): void { ob_start(); - self::assertTrue( - $this->object->exportData( - 'test_db', - 'test_table', - 'SELECT * FROM `test_db`.`test_table`;', - ), - ); + $this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;'); $result = ob_get_clean(); self::assertSame( @@ -183,13 +170,7 @@ class ExportPhparrayTest extends AbstractTestCase // case 2: test invalid variable name fix ob_start(); - self::assertTrue( - $this->object->exportData( - 'test_db', - '0`932table', - 'SELECT * FROM `test_db`.`test_table`;', - ), - ); + $this->object->exportData('test_db', '0`932table', 'SELECT * FROM `test_db`.`test_table`;'); $result = ob_get_clean(); self::assertIsString($result); diff --git a/tests/unit/Plugins/Export/ExportSqlTest.php b/tests/unit/Plugins/Export/ExportSqlTest.php index b082f179b1..7d8ba082ca 100644 --- a/tests/unit/Plugins/Export/ExportSqlTest.php +++ b/tests/unit/Plugins/Export/ExportSqlTest.php @@ -404,9 +404,7 @@ class ExportSqlTest extends AbstractTestCase $this->expectOutputString('SET FOREIGN_KEY_CHECKS=1;' . "\n" . 'COMMIT;' . "\n"); - self::assertTrue( - $this->object->exportFooter(), - ); + $this->object->exportFooter(); } public function testExportHeader(): void @@ -449,9 +447,7 @@ class ExportSqlTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue( - $this->object->exportHeader(), - ); + $this->object->exportHeader(); $result = ob_get_clean(); self::assertIsString($result); @@ -496,9 +492,7 @@ class ExportSqlTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue( - $this->object->exportDBCreate('db'), - ); + $this->object->exportDBCreate('db'); $result = ob_get_clean(); self::assertIsString($result); @@ -529,9 +523,7 @@ class ExportSqlTest extends AbstractTestCase $this->object->useSqlBackquotes(false); ob_start(); - self::assertTrue( - $this->object->exportDBCreate('db'), - ); + $this->object->exportDBCreate('db'); $result = ob_get_clean(); self::assertIsString($result); @@ -558,9 +550,7 @@ class ExportSqlTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue( - $this->object->exportDBHeader('testDB'), - ); + $this->object->exportDBHeader('testDB'); $result = ob_get_clean(); self::assertIsString($result); @@ -571,9 +561,7 @@ class ExportSqlTest extends AbstractTestCase $this->object->useSqlBackquotes(false); ob_start(); - self::assertTrue( - $this->object->exportDBHeader('testDB'), - ); + $this->object->exportDBHeader('testDB'); $result = ob_get_clean(); self::assertIsString($result); @@ -608,9 +596,7 @@ class ExportSqlTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue( - $this->object->exportEvents('db'), - ); + $this->object->exportEvents('db'); $result = ob_get_clean(); self::assertIsString($result); @@ -635,9 +621,7 @@ class ExportSqlTest extends AbstractTestCase DatabaseInterface::$instance = $dbi; ob_start(); - self::assertTrue( - $this->object->exportDBFooter('db'), - ); + $this->object->exportDBFooter('db'); $result = ob_get_clean(); self::assertSame('SqlConstraints', $result); @@ -931,7 +915,7 @@ class ExportSqlTest extends AbstractTestCase // case 1 ob_start(); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_table')); + $this->object->exportStructure('test_db', 'test_table', 'create_table'); $result = ob_get_clean(); self::assertIsString($result); @@ -942,7 +926,7 @@ class ExportSqlTest extends AbstractTestCase $this->object->useSqlBackquotes(false); ob_start(); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'triggers')); + $this->object->exportStructure('test_db', 'test_table', 'triggers'); $result = ob_get_clean(); self::assertIsString($result); @@ -957,7 +941,7 @@ class ExportSqlTest extends AbstractTestCase ExportPlugin::$exportType = ExportType::Raw; ob_start(); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_view')); + $this->object->exportStructure('test_db', 'test_table', 'create_view'); $result = ob_get_clean(); $sqlViews = (new ReflectionProperty(ExportSql::class, 'sqlViews'))->getValue($this->object); @@ -977,7 +961,7 @@ class ExportSqlTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_view')); + $this->object->exportStructure('test_db', 'test_table', 'create_view'); $result = ob_get_clean(); self::assertIsString($result); @@ -987,7 +971,7 @@ class ExportSqlTest extends AbstractTestCase // case 5 ob_start(); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'stand_in')); + $this->object->exportStructure('test_db', 'test_table', 'stand_in'); $result = ob_get_clean(); self::assertIsString($result); @@ -1222,9 +1206,7 @@ class ExportSqlTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue( - $this->object->exportData('db', 'tbl', 'SELECT'), - ); + $this->object->exportData('db', 'tbl', 'SELECT'); $result = ob_get_clean(); self::assertIsString($result); @@ -1269,9 +1251,7 @@ class ExportSqlTest extends AbstractTestCase $this->expectException(ExportException::class); $this->expectExceptionMessage('Error reading data for table db.table: err'); - self::assertTrue( - $this->object->exportData('db', 'table', 'SELECT'), - ); + $this->object->exportData('db', 'table', 'SELECT'); } public function testMakeCreateTableMSSQLCompatible(): void diff --git a/tests/unit/Plugins/Export/ExportTexytextTest.php b/tests/unit/Plugins/Export/ExportTexytextTest.php index a9b4452baa..8aaaaa9d97 100644 --- a/tests/unit/Plugins/Export/ExportTexytextTest.php +++ b/tests/unit/Plugins/Export/ExportTexytextTest.php @@ -174,38 +174,32 @@ class ExportTexytextTest extends AbstractTestCase public function testExportHeader(): void { - self::assertTrue( - $this->object->exportHeader(), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportHeader(); } public function testExportFooter(): void { - self::assertTrue( - $this->object->exportFooter(), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportFooter(); } public function testExportDBHeader(): void { $this->expectOutputString("===Database testDb\n\n"); - self::assertTrue( - $this->object->exportDBHeader('testDb'), - ); + $this->object->exportDBHeader('testDb'); } public function testExportDBFooter(): void { - self::assertTrue( - $this->object->exportDBFooter('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBFooter('testDB'); } public function testExportDBCreate(): void { - self::assertTrue( - $this->object->exportDBCreate('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBCreate('testDB'); } public function testExportData(): void @@ -216,13 +210,7 @@ class ExportTexytextTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue( - $this->object->exportData( - 'test_db', - 'test_table', - 'SELECT * FROM `test_db`.`test_table`;', - ), - ); + $this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;'); $result = ob_get_clean(); self::assertIsString($result); @@ -350,7 +338,7 @@ class ExportTexytextTest extends AbstractTestCase // case 1 ob_start(); $this->dummyDbi->addSelectDb('test_db'); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_table')); + $this->object->exportStructure('test_db', 'test_table', 'create_table'); $this->dummyDbi->assertAllSelectsConsumed(); $result = ob_get_clean(); @@ -368,7 +356,7 @@ class ExportTexytextTest extends AbstractTestCase // case 2 ob_start(); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'triggers')); + $this->object->exportStructure('test_db', 'test_table', 'triggers'); $result = ob_get_clean(); self::assertSame( @@ -383,7 +371,7 @@ class ExportTexytextTest extends AbstractTestCase // case 3 ob_start(); $this->dummyDbi->addSelectDb('test_db'); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_view')); + $this->object->exportStructure('test_db', 'test_table', 'create_view'); $this->dummyDbi->assertAllSelectsConsumed(); $result = ob_get_clean(); @@ -401,7 +389,7 @@ class ExportTexytextTest extends AbstractTestCase // case 4 ob_start(); $this->dummyDbi->addSelectDb('test_db'); - self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'stand_in')); + $this->object->exportStructure('test_db', 'test_table', 'stand_in'); $this->dummyDbi->assertAllSelectsConsumed(); $result = ob_get_clean(); diff --git a/tests/unit/Plugins/Export/ExportXmlTest.php b/tests/unit/Plugins/Export/ExportXmlTest.php index e7ae76342e..128ec33f90 100644 --- a/tests/unit/Plugins/Export/ExportXmlTest.php +++ b/tests/unit/Plugins/Export/ExportXmlTest.php @@ -249,9 +249,7 @@ class ExportXmlTest extends AbstractTestCase Current::$table = 'table'; ob_start(); - self::assertTrue( - $this->object->exportHeader(), - ); + $this->object->exportHeader(); $result = ob_get_clean(); self::assertIsString($result); @@ -313,9 +311,7 @@ class ExportXmlTest extends AbstractTestCase $this->object->setTables(['t1', 't2']); ob_start(); - self::assertTrue( - $this->object->exportHeader(), - ); + $this->object->exportHeader(); $result = ob_get_clean(); self::assertIsString($result); @@ -334,9 +330,7 @@ class ExportXmlTest extends AbstractTestCase public function testExportFooter(): void { $this->expectOutputString('</pma_xml_export>'); - self::assertTrue( - $this->object->exportFooter(), - ); + $this->object->exportFooter(); } public function testExportDBHeader(): void @@ -347,9 +341,7 @@ class ExportXmlTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue( - $this->object->exportDBHeader('&db'), - ); + $this->object->exportDBHeader('&db'); $result = ob_get_clean(); self::assertIsString($result); @@ -361,9 +353,7 @@ class ExportXmlTest extends AbstractTestCase $this->object->setExportOptions($request, []); - self::assertTrue( - $this->object->exportDBHeader('&db'), - ); + $this->object->exportDBHeader('&db'); } public function testExportDBFooter(): void @@ -374,9 +364,7 @@ class ExportXmlTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue( - $this->object->exportDBFooter('&db'), - ); + $this->object->exportDBFooter('&db'); $result = ob_get_clean(); self::assertIsString($result); @@ -388,16 +376,13 @@ class ExportXmlTest extends AbstractTestCase $this->object->setExportOptions($request, []); - self::assertTrue( - $this->object->exportDBFooter('&db'), - ); + $this->object->exportDBFooter('&db'); } public function testExportDBCreate(): void { - self::assertTrue( - $this->object->exportDBCreate('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBCreate('testDB'); } public function testExportData(): void @@ -410,13 +395,7 @@ class ExportXmlTest extends AbstractTestCase $this->object->setExportOptions($request, []); ob_start(); - self::assertTrue( - $this->object->exportData( - 'test_db', - 'test_table', - 'SELECT * FROM `test_db`.`test_table`;', - ), - ); + $this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;'); $result = ob_get_clean(); self::assertIsString($result); diff --git a/tests/unit/Plugins/Export/ExportYamlTest.php b/tests/unit/Plugins/Export/ExportYamlTest.php index e0623776a9..87339c9d09 100644 --- a/tests/unit/Plugins/Export/ExportYamlTest.php +++ b/tests/unit/Plugins/Export/ExportYamlTest.php @@ -111,9 +111,7 @@ class ExportYamlTest extends AbstractTestCase public function testExportHeader(): void { ob_start(); - self::assertTrue( - $this->object->exportHeader(), - ); + $this->object->exportHeader(); $result = ob_get_clean(); self::assertIsString($result); @@ -124,42 +122,31 @@ class ExportYamlTest extends AbstractTestCase public function testExportFooter(): void { $this->expectOutputString("...\n"); - self::assertTrue( - $this->object->exportFooter(), - ); + $this->object->exportFooter(); } public function testExportDBHeader(): void { - self::assertTrue( - $this->object->exportDBHeader('&db'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBHeader('&db'); } public function testExportDBFooter(): void { - self::assertTrue( - $this->object->exportDBFooter('&db'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBFooter('&db'); } public function testExportDBCreate(): void { - self::assertTrue( - $this->object->exportDBCreate('testDB'), - ); + $this->expectNotToPerformAssertions(); + $this->object->exportDBCreate('testDB'); } public function testExportData(): void { ob_start(); - self::assertTrue( - $this->object->exportData( - 'test_db', - 'test_table', - 'SELECT * FROM `test_db`.`test_table_yaml`;', - ), - ); + $this->object->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table_yaml`;'); $result = ob_get_clean(); self::assertSame( From 2f9158b09ae6b67d673e2b9b504645646ef3893d Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 9 Jan 2026 17:36:50 +0000 Subject: [PATCH 2/3] Split up long line Signed-off-by: Kamil Tekiela --- src/Export/Export.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Export/Export.php b/src/Export/Export.php index c899c93d4b..8bac14b557 100644 --- a/src/Export/Export.php +++ b/src/Export/Export.php @@ -586,7 +586,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; } } } From a3744fde3313aa4651f4039ed206f9a0f73e4a2c Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 9 Jan 2026 17:39:02 +0000 Subject: [PATCH 3/3] Drop exportRaw method Signed-off-by: Kamil Tekiela --- src/Controllers/Export/ExportController.php | 2 +- src/Export/Export.php | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/Controllers/Export/ExportController.php b/src/Controllers/Export/ExportController.php index 86e23c32e7..e43b570ea1 100644 --- a/src/Controllers/Export/ExportController.php +++ b/src/Controllers/Export/ExportController.php @@ -349,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 diff --git a/src/Export/Export.php b/src/Export/Export.php index 8bac14b557..c15dca2d81 100644 --- a/src/Export/Export.php +++ b/src/Export/Export.php @@ -414,21 +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 { - $exportPlugin->exportRawQuery($db, $sqlQuery); - } - /** * Export at the table level *