Skip to content

DocumentRepository::find() when ID object also contains ID field name #768

Open
@jmikola

Description

@jmikola

There appears to be logic DocumentRepository::find() to support passing a document as the $id parameter and unwrapping the identifier field value.

public function find($id, $lockMode = LockMode::NONE, $lockVersion = null)
{
    // ...

    /* TODO: What if the ID object has a field with the same name as the
     * class' mapped identifier field name?
     */
    if (is_array($id)) {
        list($identifierFieldName) = $this->class->getIdentifierFieldNames();

        if (isset($id[$identifierFieldName])) {
            $id = $id[$identifierFieldName];
        }

None of the tests in ODM depend on this functionality; however, some userland code may be. Consider removing this in 2.0.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions