-
-
Notifications
You must be signed in to change notification settings - Fork 232
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
[WIP] Configuration Validation #329
base: master
Are you sure you want to change the base?
Conversation
Moreover, I left this comment as a reminder for myself, maybe also the changelog (and the docs?) should be updated along with this PR. |
@Seldaek did you had the chance to take a look at my questions and to this PR? |
Yes I had lots of free time so I took a look and then because I am an idiot I decided not to write anything nor to act on that, and just moved on with my life. |
@Seldaek Sorry to read this. |
From my standpoint it also was not an acceptable intrusion in my inbox.. Hence the harsh reply. I know fully well that there's a ton of issues/PRs rotting away here, it sucks and I hate it but I don't have time. I'm focusing on getting Composer 2 out of the door. This project has other people able to merge stuff so I'm hoping someone else will take care of things. |
Ok, let me explain. How many times I've heard "don't open an issue and ask for others to do the work. just contribute yourself" Well, it's just what I did. Ok, shit happens and the point is not who is right or who is wrong, I'm just reflecting out loud. Apart that, I really admire your work and the time you spend on OSS. Composer is great and I'm sure Composer 2 is a big challange. I didn't intended to put pressure on you. I'm honest. If I contribute to OSS is thanks to you, Ocramius, Potencier, etc. Thanks again for all the effort and the work. |
'use_ssl', | ||
'verbosity_levels', | ||
'webhook_url', | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be generated by recursively merging $this->acceptedParamsByHandlerType
instead? So it doesn't need to be kept up to date, because I'm pretty sure it'll get outdated otherwise.
return $v; | ||
} | ||
|
||
// @todo array_keys should be converted to lowercase? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so? I don't think there is an expectation that this stuff is case insensitive generally speaking, but I might be mistaken.
return $v; | ||
} | ||
|
||
if (!array_key_exists(strtolower($v['type']), $this->acceptedParamsByHandlerType)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly to the note below, strtolower here and at line 1080 probably should be removed.. types were not case insensitive until now?
private function handlerTypeAcceptedOptionsValidation(array $v) | ||
{ | ||
if (!array_key_exists('type', $v)) { | ||
return $v; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should rather throw if type is missing? AFAIK there is no valid handler config without a type. Same below if the type is unknown I'd say throw instead of returning a valid value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By returning $v
, I let other validations to take place. Here I'm validating only if handler type has correct options, so I think it pretty safe to return $v
directly. WDYT?
Yup sorry for the rant, sometimes it's one too many and someone gets shouted at, not always deservedly so.. Anyway reviewed the PR now as penance.. The test class IMO is way too long and way too much code is spent testing invalid configs which are not really as important as valid ones. Now that the code is there though I don't know if there is much value in removing it.. I just wish it could be done more concisely and perhaps more automated, like generating those invalid config tests using a smarter provider which reads from the available params perhaps having one single provider for valid configs would help there too to be able to array_diff against that in the invalid test provider. Instead of having to write a test+provider per handler type. |
As for the test failure, I think it's an invalid config in the existing fixtures, https://github.com/symfony/monolog-bundle/blob/master/Tests/DependencyInjection/Fixtures/xml/handlers_with_channels.xml#L33 you should remove the |
Nevermind. Really. Sometime happens and realizing it is more important that the debate. Don't worry.
Yeah, indeed was one of my biggest worries about this PR. I can think of a more concise way to reach this. Meanwhile I've done the other requested things. Gonna push them in a separate and WIP commit. Thanks for having reviewed this and thank you for your time. |
4ccec5a
to
6f7ae56
Compare
6f7ae56
to
88a5a3b
Compare
I've modified tests (don't pay attention to variable name and functions name, I'll refactor if that's a good approach to you). |
This fix #325
Is worthy to note two main things:
foo
as "additional" parameter the test will pass but only becausefoo
will throw the same exception of "general acceptable" parameter but not accepted for the tested handler), b) if I use accetable parameters as explained in a) I had to make a choice to use all of them or just a random one that's not accepted. I've done all of them but if you prefer to have just a "random one" please let me know and explain why so I can modify it properly.Thanks for any feedback.