Skip to content

Auditor 3 breaks table names when using multiple "databases" #236

@timwsuqld

Description

@timwsuqld
Q A
auditor version 3.3.1
PHP version 8.2.27
Database MariaDB-10.6.8

Summary

Trying to upgrade an older Symfony 5.4 project from unsupported versions of Auditor and Auditor-Bundle as part of our migration to PHP 8.2 (and Attributes). After upgrading Doctrine DBAL to 3.6 (and disabling auditor bundle), doctrine works correctly.

After upgrading Auditor (3.3) and Auditor bundle (6.2) everything crashes with doctrine thinking the table names are now databasename__tablename. (This is just doctrine attempting to access tables, not even the at the point of writing an audit entry).

This application uses doctrine "schema" definitions, because it has models across multiple database (same server, just different MySQL databases).

The problem is in SchemaManager, resolveTableName relies on $platform->supportsSchemas(). From what I can see, this supportsSchemas isn't about the schema in an entity definition, but about things like Postgresql schemas, which is another layer of abstract on top of databases. This is causing your SchemaManager to incorrectly mangle the table names what have a schema defined, instead of passing them through as {namespaceName}.{prefix}{tablename}

Current behavior

When bundle is enabled, table names are resolved to databasename__tablename instead of databasename.tablename causing doctrine to crash and the bundle to be unusable.

How to reproduce

Setup a project with Doctrine entities that have schema defined, have multiple entities in different schemas. Create the tables manually, see that doctrine then complains that it can't find the table named databasename__tablename.

Expected behavior

Table names should be resolved to databasename.tablename

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions