[PR #5655] NamingStrategy::joinTableName not being called #9683

Closed
opened 2026-01-22 16:05:05 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/5655

State: closed
Merged: No


This problem exists for M2M without a tableName (because a NamingStrategy may take care of the table name) and XML Drivers

Explanation:

Although a joinTable MUST have an tableName eventually, it is actually valid to have it not declared IF a naming strategy would generate one (always true if not defined (null)).

However this XML driver will will parse an omitted declaration as an empty string. The ClassMetadataInfo Class is expecting an unset value or it will break.

ClassMetadataInfo will show a Notice: Uninitialized string offset: 0 which makes sense if you look at

// remember $mapping['joinTable']['name'] is now "";
if (isset($mapping['joinTable']['name']) && $mapping['joinTable']['name'][0] === '`') {

see

More importantly the (default) naming strategy will now never be called and the resulting ClassMetadataInfo has no table name defined, which results in a 'Invalid table name specified' Exception

if ( ! isset($mapping['joinTable']['name'])) {
    $mapping['joinTable']['name'] = $this->namingStrategy->joinTableName($mapping['sourceEntity'], $mapping['targetEntity'], $mapping['fieldName']);
}

see

Please tell me if this is something we can merge without further proof, I don't really understand how to add a test case for it (I have looked at the existing cases, but... pfft)

**Original Pull Request:** https://github.com/doctrine/orm/pull/5655 **State:** closed **Merged:** No --- This problem exists for M2M without a tableName (because a NamingStrategy may take care of the table name) and XML Drivers Explanation: Although a joinTable MUST have an tableName eventually, it is actually valid to have it not declared IF a naming strategy would generate one (always true if not defined (null)). However this XML driver will will parse an omitted declaration as an empty string. The ClassMetadataInfo Class is expecting an unset value or it will break. ClassMetadataInfo will show a `Notice: Uninitialized string offset: 0` which makes sense if you look at ``` // remember $mapping['joinTable']['name'] is now ""; if (isset($mapping['joinTable']['name']) && $mapping['joinTable']['name'][0] === '`') { ``` [see](https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1521) More importantly the (default) naming strategy will now never be called and the resulting ClassMetadataInfo has no table name defined, which results in a 'Invalid table name specified' Exception ``` if ( ! isset($mapping['joinTable']['name'])) { $mapping['joinTable']['name'] = $this->namingStrategy->joinTableName($mapping['sourceEntity'], $mapping['targetEntity'], $mapping['fieldName']); } ``` [see](https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1703-L1705) Please tell me if this is something we can merge without further proof, I don't really understand how to add a test case for it (I have looked at the existing cases, but... pfft)
admin added the pull-request label 2026-01-22 16:05:05 +01:00
admin closed this issue 2026-01-22 16:05:06 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9683