ParameterHandler icon indicating copy to clipboard operation
ParameterHandler copied to clipboard

Handle constants from .dist

Open fullmoonissue opened this issue 9 years ago • 8 comments

I have a use case where the mcrypt cipher and mode are stored into the .dist file.

parameters:
    cipher: !php/const:MCRYPT_RIJNDAEL_128
    mode: !php/const:MCRYPT_MODE_CBC

After the build of the parameters.yml file, these two keys are set to null.

I can submit a PR to correct that case but I just wanted to know your opinion about this issue.

Regards,

fullmoonissue avatar Dec 19 '16 21:12 fullmoonissue

This bug was declared in 2016.. We're in 2018 and the issue is still there. Please answer so that this can be fixed asap.

rrajkomar avatar May 02 '18 07:05 rrajkomar

I don't think this can be fixed easily. The YAML parser will replace the constant with its actual value at runtime, so the dumper will only be able to dump this value but not the constant.

xabbuh avatar May 02 '18 09:05 xabbuh

Actually no, it should an easy fix . In case the parameter value starts with "!php/const" the whole parameter should be simply be copied to the parameters.yml file and not evaluated. Evaluation is the job of the application. Simplest way to verify that is to manually copy the value from parameters.yml.dist to parameters.yml and, as long as the value is correct, the application will be able to resolve the value on its own.

rrajkomar avatar May 02 '18 09:05 rrajkomar

@rrajkomar was correct, it was an easy fix, it just needed an argument to tell it to do so

edit: but this ticket is so old that @fullmoonissue will not be able to use !php/const:MCRYPT_MODE_CBC you will most likely need !php/const MCRYPT_MODE_CBC because the colon notation is depreciated

EntranceJew avatar Jul 26 '18 01:07 EntranceJew

Thank you @rrajkomar and @EntranceJew for taking care of this forgotten issue.

In fact, @EntranceJew your PR was what I wanted to submit (the addition of Yaml::PARSE_CONSTANT and the related tests).

But as @xabbuh mentioned, it resolves the value at runtime and the constant name is not preserved (which will fix my initial issue by the way).

Two years have passed, the DotEnv Component was released and mcrypt was deprecated (even removed in php 7.2) so my issue is become obsolete (for my specific concern).

I let @xabbuh and @stof decide about these issue.

Good bye everyone and wishing to all of you the best.

Kind regards,

fullmoonissue avatar Jul 28 '18 10:07 fullmoonissue

Hello, i encounter the same problem , is there a future fix for that ? Thanks

chaouchAbderraouf avatar Jul 30 '18 12:07 chaouchAbderraouf

+1 for this one and proposed PR

TiS avatar Feb 21 '19 18:02 TiS

@xabbuh I understand your concern about replacing the constant with its actual value instead of keeping the constant... but I think it would still be a lot better than replacing it with null 😄

Oliboy50 avatar May 07 '20 10:05 Oliboy50