8000 [DI] XmlFileLoader bad error message · Issue #35886 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[DI] XmlFileLoader bad error message #35886
Closed
@ro0NL

Description

@ro0NL

Today we debugged an error message coming from XmlFileLoader in the DI component:

File some.xml does not contain valid XML, it is empty.

Coming from

$content = @file_get_contents($file);
if ('' === trim($content)) {
throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));
}

The file is not empty :) removing the @ reveals the true error:

PHP Warning:  file_get_contents(file.ext): failed to open stream: Permission denied 

So if $content is false (before trim casts to string) we cant assume an empty file. Ideally the original errors bubbles up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDXDX = Developer eXperience (anything that improves the experience of using Symfony)DependencyInjection

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0