[3.0] Lets table_sql read a column that has no default - #9651
Open
albertlast wants to merge 1 commit into
Open
Conversation
information_schema.columns.column_default is null for a column without one, and trim() has not taken null since PHP 8.1. The file declares strict_types, so the first such column ends the method rather than being passed over, and every table has one. 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
table_sql()cannot run on PostgreSQL. It ends on the first column that has no default, which every table has:information_schema.columns.column_defaultis null for a column that has no default, and the code askstrim()about it before looking:trim(null)has been deprecated since PHP 8.1, and the file declaresstrict_types, so it is aTypeErrorrather than a notice. The intent is already there in the comparison against''; only the null has to reach it.Nothing in SMF calls
table_sql(), which is why this has gone unnoticed. It is public API and reachable through thedb_table_sqlalias inDatabaseApi::$db_function_map, so a mod calling it on PostgreSQL gets a fatal.With the null handled, the method does what it says. For
smf_boards:How this was verified
Against a PostgreSQL forum upgraded from the 2.1.7 baseline, calling
Db::$db->table_sql()through SSI: fatal on every table before, and the definition above after. The sequence, the defaults, the indexes and the primary key are all in it, andSTART WITH 25matches the 24 boards the baseline holds.MySQL reaches the same information through
table_structure()and does not readcolumn_defaultthis way, so it is unaffected.Not reachable from the unit suite
table_sql()is a database driver method and needs a connection.Issues References (Fixes|Related|Closes)