-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
RequestSchema constructor fails silently on bad filename #1216
Comments
Which should throw an exception in You could test it manually using
and post the result. |
I think
And won't throw an exception here : Moving it to false would be a big change that could impact other system though. I should probably test for this situation on the V5 branch. |
FYI, most PHP install will suppress E_WARNING by default. try/catch doesn't work because a warning is not an exception, so there's no way to handle this, only the |
Fix userfrosting/UserFrosting#1216 + Remove deprecated method
I fixed this in userfrosting/framework@4bfc0fc on the V5 branch. A I don't plan on fixing for V4, but a PR would be considered. |
Current Behavior:
Sending an invalid filename to
new RequestSchema($path);
appears to result in an empty Schema.(There should be a warning in the PHP error log, but I'm unable to confirm this right now.)
The presenting issue in chat was
$transformer->transform
returning an unexpected blank array, due to a bad path or filename in the $schema sent to $transformer.Expected Behavior:
The UF docs use a bad filename as an example of a runtime error.
UF should catch this and throw a runtime error, as PHP appears to treat this with just a warning.
Discussion:
If I'm reading the code correctly, the
RequestSchema
constructor usesfile_get_contents($path)
. Per PHP.net,An E_WARNING level error is generated if filename cannot be found
.That warning doesn't seem to be caught by UF, so it should just end up in the PHP error log.
I'm surprised that PHP only creates an
E_WARNING
here, but that's outside this project's scope.I'm currently having some troubles with my PHP error log, and getting intermittent UF error-renderer failures as well. Potentially this error should be more visible and I simply have something additional broken.
Possible Solutions:
new RequestSchema($path);
to escalate this up fromE_WARNING
to something more noticeable.new RequestSchema('schema://BadDirectory/ThisIsNotARealFile.yaml');
shows an error rather than failing silently, feel free to close this and I will fix my install instead :)The text was updated successfully, but these errors were encountered: