[3.0] Returns a bool from the substep that backs up a table - #9649
Open
albertlast wants to merge 1 commit into
Open
[3.0] Returns a bool from the substep that backs up a table#9649albertlast wants to merge 1 commit into
albertlast wants to merge 1 commit into
Conversation
doBackupTable() is declared to return bool and hands back whatever Db::$db->backup_table() gave it, which the database interface declares as object|bool. PostgreSQL answers a CREATE TABLE with a result object, so the declaration is violated and the upgrade stops at the first table it tries to back up. MySQL answers true, which is why only one engine shows it. Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On PostgreSQL, an upgrade that was asked to back up the database stops at the first table it tries to copy:
doBackupTable()is declared: booland returns the database layer's answer unchanged:DatabaseApiInterfacedeclares that answer asobject|bool, and the two engines use both halves of it.PostgreSQL::backup_table()returns the result of itsCREATE TABLE, whichpg_query()answers with aPgSql\Result;MySQL::backup_table()returns the result of the same statement, whichmysqlianswers withtrue. The file isdeclare(strict_types=1), so one engine returns a bool and the other throws.GenericSubStep::execute()treats a false return as a failed substep, and that is the signal worth keeping, so this compares againstfalserather than casting.This has been the case since
e963318b8, which moved the backup loop into substeps. The code before it discarded the return value and left a note about this exact thing:It survives because the command line skips the backup step unless something asks for it, so an automated run never reaches this. In a browser the checkbox is ticked by default, which makes this the ordinary path for someone upgrading a PostgreSQL forum by hand.
How this was verified
Upgrading the 2.1.7 baseline from the 2.1 development environment, with the backup step turned on, on both engines:
The PostgreSQL run then reaches a second, unrelated fault in
backup_table()itself, which is #9650. Both were applied together to confirm the upgrade finishes; this change alone moves the failure rather than removing it.Also checked with the upgrade killed part way and started again, at 25% and 75% of the substeps, with backups on. Both recovered in one run, and every non-
backup_object matched an uninterrupted upgrade: all 323 tables, sequences, indexes, constraints, functions, aggregates and operators, 65 row counts and 228 settings.Not reachable from the unit suite
doBackupTable()needsDb::$db, and telling the two engines apart is the whole of the behaviour.Issues References (Fixes|Related|Closes)