fix: DatabaseDumper dumpToFile() double-escapes newline after DROP TABLE #179

Open
opened 2026-06-29 14:39:34 +00:00 by jmiller · 2 comments
Owner

Summary

DatabaseDumper.php:329fwrite($fp, 'DROP TABLE IF EXISTS \' . $abstractName . "\;\\n");

The double-escaped backslash produces literal \n in the SQL file instead of a newline. This concatenates the DROP TABLE statement with the CREATE TABLE statement, producing invalid SQL on import.

The in-memory dump() method doesn't have this issue — only the streaming dumpToFile() path (used by BackupEngine).

Severity

Critical — corrupts every database backup created via the streaming path.

Location

source/packages/com_mokosuitebackup/src/Engine/DatabaseDumper.php:329

Fix

Change "\\;\n"to"`;\n"` (single-escaped newline).

## Summary `DatabaseDumper.php:329` — `fwrite($fp, 'DROP TABLE IF EXISTS \`' . $abstractName . "\\`;\\n");` The double-escaped backslash produces literal `\n` in the SQL file instead of a newline. This concatenates the DROP TABLE statement with the CREATE TABLE statement, producing invalid SQL on import. The in-memory `dump()` method doesn't have this issue — only the streaming `dumpToFile()` path (used by BackupEngine). ## Severity **Critical** — corrupts every database backup created via the streaming path. ## Location `source/packages/com_mokosuitebackup/src/Engine/DatabaseDumper.php:329` ## Fix Change `"\\`;\\n"` to `"\`;\n"` (single-escaped newline).
jmiller added the component: engine label 2026-06-29 14:39:34 +00:00
Author
Owner

Branch created: feature/179-fix-databasedumper-dumptofile-double-esc

git fetch origin
git checkout feature/179-fix-databasedumper-dumptofile-double-esc
Branch created: [`feature/179-fix-databasedumper-dumptofile-double-esc`](https://git.mokoconsulting.tech/MokoConsulting/MokoSuiteBackup/src/branch/feature/179-fix-databasedumper-dumptofile-double-esc) ```bash git fetch origin git checkout feature/179-fix-databasedumper-dumptofile-double-esc ```
Author
Owner

Confirmed present in 02.56.05 — keep open.

DatabaseDumper.php:329 writes 'DROP TABLE IF EXISTS \' . $abstractName . "`;\n"— the\n in that double-quoted string emits a literal backslash+n, not a newline. Line 330 correctly uses "\n\n". Fix: change "`;\n"to"`;\n"`.

Confirmed present in 02.56.05 — keep open. `DatabaseDumper.php:329` writes `'DROP TABLE IF EXISTS \`' . $abstractName . "\`;\\n"` — the `\\n` in that double-quoted string emits a literal backslash+`n`, not a newline. Line 330 correctly uses `"\n\n"`. Fix: change `"\`;\\n"` to `"\`;\n"`.
Sign in to join this conversation.