[ticket/17625] Keep foreign database tables out of schema operations#7000
Open
ECYaz wants to merge 1 commit into
Open
[ticket/17625] Keep foreign database tables out of schema operations#7000ECYaz wants to merge 1 commit into
ECYaz wants to merge 1 commit into
Conversation
Scope Doctrine schema introspection and the duplicated-index-name migration to tables carrying the configured table prefix, and map MySQL's ENUM type to string, so tables not created by phpBB sharing the database cannot break installation or schema changes. PHPBB-17625
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.
Installing phpBB into a database that already contains tables not created by phpBB (shared hosting setups, or a database also holding an old board) fails with
Unknown database type enum requested— Doctrine'sintrospectSchema()reads every table in the database, and foreign tables can use column types Doctrine has no mapping for, such as MySQL's nativeENUM. In addition, therename_duplicated_index_namesmigration collects index names from every table in the database, so foreign tables leak into the generated install schema (thebbdkp_registercreate step visible in the ticket's stack trace) and it fatals witharray_keys(null)when no such table carries a secondary index.This PR scopes schema operations to phpBB's own tables:
phpbb\db\tools\doctrine::get_schema()now sets a Doctrine schema assets filter restricted to the configured table prefix for the duration of the introspection (restoring any previous filter afterwards, chaining one if set, matching case-insensitively since some databases fold identifier case). Foreign tables can no longer breaksql_create_table()or column/index operations, regardless of their column types. The filter is deliberately scoped toget_schema()sosql_table_exists()/sql_list_tables()behaviour is unchanged.rename_duplicated_index_names::get_tables_index_names()only collects index names from tables carrying the table prefix, and initialises its static cache so a database without eligible tables no longer fatals. This also stops the migration from renaming indexes of another application's tables (or another board's, when two boards with different prefixes share one database).phpbb\db\doctrine\connection_factoryadditionally maps MySQL'senumtype tostringas defense in depth for foreign tables that do share the prefix.Verified end to end: a CLI install (
install/phpbbcli.php install) into a MySQL database containing a pre-existingENUM-typed table completes successfully (76 tables created, the foreign table untouched); on current master the same install fatals with the ticket's exact stack trace. Regression tests cover the Doctrine tools path per DBMS (MySQLENUM, PostgreSQLCREATE TYPE … AS ENUM, SQLite unknown declared type) and the migration's index-name collection.Checklist:
Tracker ticket:
https://tracker.phpbb.com/browse/PHPBB-17625