DDC-3551: [GH-1294] Avoid Connection error when calling ClassMetadataFactor::getAllMetadata() #4370

Closed
opened 2026-01-22 14:40:22 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 29, 2015).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of weaverryan:

Url: https://github.com/doctrine/doctrine2/pull/1294

Message:

Hi guys!

When you pair the ORM with DBAL 2.5.0, then getting the targetPlatform means that a connection will be made to the database. For that reason, it's really important to not get the targetPlatform unless it's absolutely needed. Currently, if you call ClassMetadataFactor::getAllMetadata(), it will try to determine targetPlatform (in initialize()), which will make a connection. And if that connection fails (e.g. no db yet), it will blow up - even though getAllMetadata() doesn't need the targetPlatform.

This fixes that, and in an absolutely BC way, since targetPlatform is private (yay!). This should fix a number of issues in userland, like symfony/symfony-standard#748 and symfony/symfony-standard#774.

This is a PR to master (per the guidelines), but the real target is 2.4, since it's the latest stable. The patch won't apply cleanly, but it's simple: remove from initialize, then replace all references to the new private method.

Thanks in advance! More details are on the commit message.

Originally created by @doctrinebot on GitHub (Jan 29, 2015). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of weaverryan: Url: https://github.com/doctrine/doctrine2/pull/1294 Message: Hi guys! When you pair the ORM with DBAL 2.5.0, then getting the `targetPlatform` means that a connection will be made to the database. For that reason, it's really important to **not** get the `targetPlatform` unless it's absolutely needed. Currently, if you call `ClassMetadataFactor::getAllMetadata()`, it will try to determine `targetPlatform` (in `initialize()`), which will make a connection. And if that connection fails (e.g. no db yet), it will blow up - even though `getAllMetadata()` doesn't need the `targetPlatform`. This fixes that, and in an absolutely BC way, since `targetPlatform` is private (yay!). This should fix a number of issues in userland, like symfony/symfony-standard#748 and symfony/symfony-standard#774. This is a PR to master (per the guidelines), but the real target is 2.4, since it's the latest stable. The patch won't apply cleanly, but it's simple: remove from initialize, then replace all references to the new private method. Thanks in advance! More details are on the commit message.
admin added the Bug label 2026-01-22 14:40:22 +01:00
admin closed this issue 2026-01-22 14:40:23 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 4, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1294] was merged:
https://github.com/doctrine/doctrine2/pull/1294

@doctrinebot commented on GitHub (Feb 4, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1294] was merged: https://github.com/doctrine/doctrine2/pull/1294
Author
Owner

@doctrinebot commented on GitHub (Feb 4, 2015):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-1294] was assigned:
https://github.com/doctrine/doctrine2/pull/1294

@doctrinebot commented on GitHub (Feb 4, 2015): Comment created by @doctrinebot: A related Github Pull-Request [GH-1294] was assigned: https://github.com/doctrine/doctrine2/pull/1294
Author
Owner

@doctrinebot commented on GitHub (Feb 4, 2015):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Feb 4, 2015): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#4370