Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DI] XmlFileLoader bad error message #35886

Closed
ro0NL opened this issue Feb 27, 2020 · 2 comments
Closed

[DI] XmlFileLoader bad error message #35886

ro0NL opened this issue Feb 27, 2020 · 2 comments
Labels
Bug DependencyInjection DX DX = Developer eXperience (anything that improves the experience of using Symfony)

Comments

@ro0NL
Copy link
Contributor

ro0NL commented Feb 27, 2020

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.

@ro0NL ro0NL added the Bug label Feb 27, 2020
@xabbuh xabbuh added DependencyInjection DX DX = Developer eXperience (anything that improves the experience of using Symfony) labels Feb 27, 2020
@przemyslaw-bogusz
Copy link
Contributor

@ro0NL Are you looking for volunteers?

@ro0NL
Copy link
Contributor Author

ro0NL commented Mar 1, 2020

Yes, go for it :}

@fabpot fabpot closed this as completed Mar 6, 2020
fabpot added a commit that referenced this issue Mar 6, 2020
This PR was squashed before being merged into the 3.4 branch.

Discussion
----------

[DI] Fix XmlFileLoader bad error message

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35886
| License       | MIT
| Doc PR        |

Commits
-------

be7afc6 [DI] Fix XmlFileLoader bad error message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug DependencyInjection DX DX = Developer eXperience (anything that improves the experience of using Symfony)
Projects
None yet
Development

No branches or pull requests

4 participants