Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix ConsoleFormatter - call to a member function format() on string#31326

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:3.4fromkeksa:feature/console-formatter-datetime-fix
May 1, 2019
Merged

fix ConsoleFormatter - call to a member function format() on string#31326

fabpot merged 1 commit intosymfony:3.4fromkeksa:feature/console-formatter-datetime-fix
May 1, 2019

Conversation

@keksa
Copy link
Contributor

QA
Branch?3.4
Bug fix?yes
New feature?no
BC breaks?maybe
Deprecations?no
Tests pass?yes
Fixed tickets-
LicenseMIT
Doc PR-

The ConsoleFormatter crashes when there is not a DateTime object in$record['datetime']. As this parameter is not documented anywhere (i.e.FormatterInterface does not say it must be a DateTime object), I think the proper fix is to check if there is DateTimeInterface object and only call theformat method then.

We use a custom LogProcessor (https://symfony.com/doc/current/logging/processors.html) to add some extra data and format the DateTime in the$record['datetime']. We need to format the DateTime in the processor, because we useJsonFormatter in prod environment and it does not support changing the date format. We useConsoleFormatter only in dev environment and as the processor is called before the formatter, we get the crash.

There were no tests whatsoever forConsoleFormatter, so I've added a basic one, that passes before and after, and another one that tests the crash (failed before, passed after).

There is a theoretical BC break, as someone could have sent an object with aformat method to the formatter and it would have worked, but I'm not sure if it's considered BC break by Symfony, please let me know, if it is.

ro0NL reacted with thumbs up emoji

namespace Symfony\Bridge\Monolog\Tests\Formatter;

use DateTime;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

we dont use root classes :) should be prefixed with\

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fixed, thank you

@keksa
Copy link
ContributorAuthor

The failing tests seem unrelated, they're failing in other PRs too.

@nicolas-grekasnicolas-grekas added this to the3.4 milestoneApr 30, 2019
@fabpot
Copy link
Member

Thank you@keksa.

@fabpotfabpot merged commit6488328 intosymfony:3.4May 1, 2019
fabpot added a commit that referenced this pull requestMay 1, 2019
…on string (keksa)This PR was merged into the 3.4 branch.Discussion----------fix ConsoleFormatter - call to a member function format() on string| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| BC breaks?    | maybe| Deprecations? | no| Tests pass?   | yes| Fixed tickets | -| License       | MIT| Doc PR        | -The ConsoleFormatter crashes when there is not a DateTime object in `$record['datetime']`. As this parameter is not documented anywhere (i.e. `FormatterInterface` does not say it must be a DateTime object), I think the proper fix is to check if there is DateTimeInterface object and only call the `format` method then.We use a custom LogProcessor (https://symfony.com/doc/current/logging/processors.html) to add some extra data and format the DateTime in the `$record['datetime']`. We need to format the DateTime in the processor, because we use `JsonFormatter` in prod environment and it does not support changing the date format. We use `ConsoleFormatter` only in dev environment and as the processor is called before the formatter, we get the crash.There were no tests whatsoever for `ConsoleFormatter`, so I've added a basic one, that passes before and after, and another one that tests the crash (failed before, passed after).There is a theoretical BC break, as someone could have sent an object with a `format` method to the formatter and it would have worked, but I'm not sure if it's considered BC break by Symfony, please let me know, if it is.Commits-------6488328 fix ConsoleFormatter - call to a member function format() on string
@keksakeksa deleted the feature/console-formatter-datetime-fix branchMay 1, 2019 10:55
This was referencedMay 1, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@OskarStarkOskarStarkOskarStark approved these changes

+1 more reviewer

@ro0NLro0NLro0NL approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

6 participants

@keksa@fabpot@OskarStark@ro0NL@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp