-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Fix Test Logger monolog compatibility #35596
Conversation
# System info - Magento 2.4.4 - PHP 8.1 # To reproduce 1. Get a setup of 2.4.4 installed 2. See that in the constraints allow for an install of `monolog/logger` at `2.7.0` 3. Try to run integration tests (https://devdocs.magento.com/guides/v2.4/test/integration/integration_test_execution.html) # The error Currently we get this error because the method signatures are different ``` PHP Fatal error: Declaration of Magento\TestFramework\ErrorLog\Logger::addRecord(int $level, string $message, array $context = []): bool must be compatible with Monolog\Logger::addRecord(int $level, string $message, array $context = [], ?Monolog\DateTimeImmutable $datetime = null): bool in dev/tests/integration/framework/Magento/TestFramework/ErrorLog/Logger.php on line 69 ``` # Root cause This version of `monlog/logger` was tagged about an hour ago https://github.com/Seldaek/monolog/releases/tag/2.7.0 See this entry > Added $datetime parameter to Logger::addRecord as low level API to allow logging into the past or future (Seldaek/monolog#1682) Which goes along with this commit Seldaek/monolog@0ddba73#diff-1e7fd545cec457de96f5ed6bd7249ba091cd9e699b4057db15ff1e2e0364025bR297 This changes the method signature of `addRecord` like so ```diff - public function addRecord(int|Level $level, string $message, array $context = []): bool + public function addRecord(int|Level $level, string $message, array $context = [], DateTimeImmutable $datetime = null): bool ``` See the magento core logger is defined like this https://github.com/magento/magento2/blob/a8543fed035d85c667195e95f69476d51f98381b/dev/tests/integration/framework/Magento/TestFramework/ErrorLog/Logger.php#L69-L73 The method signature needs to be updated to match `monolog/logger` definition
Hi @convenient. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review. For more details, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run all tests |
1 similar comment
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
I dont know how your static tests are bootstrapped but evidently not pulling in the new version of monolog. When i do a |
@magento run Unit Tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
Hi @convenient you'll probably want to add If you look at Monolog they're using their own class for DateTimeImmutable We ran across this same problem in the Drupal monolog module: https://www.drupal.org/project/monolog/issues/3284825 |
Huh thanks @zrpnr I didn't spot that was just aiming for green tests 😅 |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Functional Tests EE, Functional Tests CE, Functional Tests B2B |
Before I spend any time fighting test cases can I please have some feedback on the official monolog stance on what Magento is doing here, see Seldaek/monolog#1684 (comment)
Seems to me using a handler is the right thing to do here |
Looks like in Magento 2.4.5 we have a fix for this issue with the same changes 360fd1b |
Thanks for the fyi @ihor-sviziev . I did spot this in the pre release a week or so back. In these scenarios I wonder why my commits aren't cherry picked or merged rather than doing new ones. attribution isn't a massive deal but I've clearly done the leg work here From identifying the issue (an hour or so after it appeared), to writing a bug report, speaking with the upstream developers, and trying to have a communication with Magento about a better way of fixing it than what was in this PR. |
@convenient true! |
Hello @convenient and @ihor-sviziev Thank you for pointing out this situation! Unfortunately, I do not have a clear and transparent answer to "Why did it happen?" We are working with teams and @mahesh-singh-rajawat to prevent this kind of situation in future Sorry for the incident and any inconveniences cc: @sidolov |
Not sure if this is the preferred approach, but one of our automated suites which builds magento with our module caught this today.
System info
To reproduce
monolog/monolog
at2.7.0
The error
Currently we get this error because the method signatures are different
Root cause
This version of
monolog/monolog
was tagged about an hour ago https://github.com/Seldaek/monolog/releases/tag/2.7.0See this entry
Which goes along with this commit
Seldaek/monolog@0ddba73#diff-1e7fd545cec457de96f5ed6bd7249ba091cd9e699b4057db15ff1e2e0364025bR297
This changes the method signature of
addRecord
like soSee the magento core logger is defined like this
magento2/dev/tests/integration/framework/Magento/TestFramework/ErrorLog/Logger.php
Lines 69 to 73 in a8543fe
The method signature needs to be updated to match
monolog/monolog
definitionContribution checklist (*)