Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Problem with unescaping class arguments #2

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

Closed
wants to merge 1 commit into from
Closed

Problem with unescaping class arguments #2

wants to merge 1 commit into from

Conversation

avorobiev
Copy link

I've got an error when I tried to use DI to initiate Monolog logger with next settings:

services:
  logger_formatter:
    class:        \Monolog\Formatter\LineFormatter
    arguments:    [ "[%%datetime%%] %%channel%%.%%level_name%%: %%message%% %%context%%\n" ]  
  logger_handler:
    class:        \Monolog\Handler\StreamHandler
    arguments:
      - app.log
      - <?php echo \Monolog\Logger::DEBUG, PHP_EOL; ?>
    calls:
      - [ setFormatter, [ @logger_formatter ]]
  logger:
    class:        \Monolog\Logger
    arguments:    [ 'logger_name' ]
    calls:
      - [ pushHandler, [ @logger_handler ]]

If I set argument for service logger_formatter with single % (like "[%datetime%]…") then DI threw exception that it could not resolve reference because there was non-existent parameter "datetime".
If I set argument with double % (like "[%%datetime%%]…") then DI transferred parameter to the LineFormatter object without unescaping, and LineFormatter did not work properly.
The problem was in ContainerBuilder, because there was no unescaping class parameters.

I’ve fixed problem and added tests to cover such case.

@cursedcoder
Copy link

Hello, this repository is a read-only, so if you want to PR something, then pull it there https://github.com/symfony/symfony/pulls

@avorobiev
Copy link
Author

Moved to symfony/symfony#4665

@avorobiev avorobiev closed this Jun 26, 2012
symfony-splitter pushed a commit that referenced this pull request Sep 4, 2018
This PR was merged into the 4.2-dev branch.

Discussion
----------

Mark ExceptionInterfaces throwable #2

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This has been reverted in beta of 4.1 because of lack of support in prophecy, which has been fixed since then (incl. release). Can be merged again.

References:
symfony/symfony#26702
symfony/symfony#27420
symfony/symfony#27419
phpspec/prophecy#412

ping @dunglas @ciaranmcnulty @dkarlovi @Wirone @teohhanhui @stof @nicolas-grekas @ondrejmirtes

Commits
-------

17c3675226 Mark ExceptionInterfaces throwable
symfony-splitter pushed a commit that referenced this pull request Dec 17, 2021
DOMElement::setAttribute(): Passing null to parameter #2 ($value) of type string is deprecated

This happens when a tag value is `null` on PHP 8.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants