Skip to content

[ticket/17625] Keep foreign database tables out of schema operations#7000

Open
ECYaz wants to merge 1 commit into
phpbb:masterfrom
ECYaz:ticket/17625
Open

[ticket/17625] Keep foreign database tables out of schema operations#7000
ECYaz wants to merge 1 commit into
phpbb:masterfrom
ECYaz:ticket/17625

Conversation

@ECYaz

@ECYaz ECYaz commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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's introspectSchema() reads every table in the database, and foreign tables can use column types Doctrine has no mapping for, such as MySQL's native ENUM. In addition, the rename_duplicated_index_names migration collects index names from every table in the database, so foreign tables leak into the generated install schema (the bbdkp_register create step visible in the ticket's stack trace) and it fatals with array_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 break sql_create_table() or column/index operations, regardless of their column types. The filter is deliberately scoped to get_schema() so sql_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_factory additionally maps MySQL's enum type to string as 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-existing ENUM-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 (MySQL ENUM, PostgreSQL CREATE TYPE … AS ENUM, SQLite unknown declared type) and the migration's index-name collection.

Checklist:

  • Correct branch: master for new features; 3.3.x for fixes
  • Tests pass
  • Code follows coding guidelines: master and 3.3.x
  • Commit follows commit message format

Tracker ticket:

https://tracker.phpbb.com/browse/PHPBB-17625

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant