Skip to content

SymfonyFileLocator triggers an assertion for DateTime params #520

Description

@pontus-mp

Bug Report

Q A
Version 3.6.8

Summary

Using DateTime (or other global namespace classes) with assertions enabled can cause an assertion failure in SymfonyFileLocator.

Current behavior

assert(is_int($pos)); fails if $className doesn't contain a \, which is the case for DateTime.

Expected behavior

Not triggering an assert, obviously, but I'm not well-versed enough in doctrine internals to say how it should work. Either the assert should be removed (and the following exception adjusted accordingly) or findMappingFile shouldn't be called in the first place.

How to reproduce

A quite tiny repro:

$locator = new Doctrine\Persistence\Mapping\Driver\SymfonyFileLocator([]);
$locator->findMappingFile(DateTime::class);

A more realistic way to trigger this is to call \Doctrine\ORM\AbstractQuery::setParameter with a DateTime as value but WITHOUT explicitly declaring the type in the third (type) parameter:
$someQuery->setParam('foo', new DateTime());

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingGood First IssueGood for newcomers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions