Skip to content

[MonologBridge] Fix debug processor datetime type #34601

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

Merged
merged 1 commit into from
Dec 10, 2019
Merged

[MonologBridge] Fix debug processor datetime type #34601

merged 1 commit into from
Dec 10, 2019

Conversation

mRoca
Copy link
Contributor

@mRoca mRoca commented Nov 25, 2019

Q A
Branch? 3.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets n/a
License MIT
Doc PR n/a

This PR fixes an eventual Call to a member function getTimestamp() on string if any Processor transforms the datetime value, and uses the same record conditions as in the ConsoleFormatter

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Could you please add a test case? Not that this should be for branch 3.4, where the bug is apparently.

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Nov 25, 2019
@mRoca mRoca changed the base branch from 5.0 to 3.4 November 25, 2019 16:15
@mRoca
Copy link
Contributor Author

mRoca commented Nov 25, 2019

Target branch is now 3.4, and tests have been added.

The bug is still present in the DebugHandler, which have been deprecated in 3.2, then deleted in 4.0. Should I fix it and add tests ?

return [
[array_merge($record, ['datetime' => new \DateTime('2019-01-01T00:01:00+00:00')]), 1546300860],
[array_merge($record, ['datetime' => '2019-01-01T00:01:00+00:00']), 1546300860],
[array_merge($record, ['datetime' => 'foo']), false],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

What should the timestamp field contain if datetime is not a valid value ? As the DebugProcessor is not called before other processors, the data can be corrupted.

Copy link
Member

Choose a reason for hiding this comment

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

the original value could be the best

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Nov 25, 2019

The bug is still present in the DebugHandler

let's fix it then, branch 4.3 because 4.2 is not maintained anymore

What should the timestamp field contain if datetime is not a valid value ?

I don't know, this looks good enough to me.

@nicolas-grekas
Copy link
Member

Thank you @mRoca.

nicolas-grekas added a commit that referenced this pull request Dec 10, 2019
This PR was merged into the 3.4 branch.

Discussion
----------

[MonologBridge] Fix debug processor datetime type

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |n/a
| License       | MIT
| Doc PR        | n/a

This PR fixes an eventual `Call to a member function getTimestamp() on string` if any Processor transforms the `datetime` value, and uses the same record conditions as in the [ConsoleFormatter](https://github.com/symfony/monolog-bridge/blob/master/Formatter/ConsoleFormatter.php#L118 )

Commits
-------

ffe3f10 [MonologBridge] Fix debug processor datetime type
@nicolas-grekas nicolas-grekas merged commit ffe3f10 into symfony:3.4 Dec 10, 2019
@mRoca mRoca deleted the monolog_bridge_debug_datetime branch December 10, 2019 12:19
This was referenced Dec 19, 2019
This was referenced Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants