magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.54k stars 9.32k forks source link

Monolog issue #35604

Closed Nuranto closed 2 years ago

Nuranto commented 2 years ago

Preconditions and environment

Steps to reproduce

  1. composer update
  2. bin/magento setup:upgrade

Expected result

Everything works fine

Actual result

PHP Fatal error:  Declaration of Migration\Logger\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 /var/www/html/vendor/magento/data-migration-tool/src/Migration/Logger/Logger.php on line 34

Additional information

Monolog 2.7.0 has bee released yesterday, and have breaking changes.

Quick Solution : fix dependency to 2.6.0 Best Solution : fix compatibility issues

Note that everyone who upgrades to 2.4.4 from now will probably have this issue.

Quick solution for devs who don't want to wait for a fix & release : composer require monolog/monolog:2.6.0

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @Nuranto. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues 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.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

mrtuvn commented 2 years ago

i think we should report here https://github.com/magento/data-migration-tool/issues

convenient commented 2 years ago

Similar to this https://github.com/magento/magento2/pull/35596 which affects integration tests

m2-assistant[bot] commented 2 years ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 2 years ago

Hi @Nuranto , Thank you for reporting and collaboration. Verified the issue by upgrading from 2.4.3-p1 to 2.4.4 but could not able to reproduce the issue. Steps performed:

  1. Installed 2.4.3-p1 project-community-edition with PHP7.4
  2. Upgraded to 2.4.4 project-community-edition (Ref upgrade guide:
  3. Ran composer update
  4. Ran: php bin/magento setup:upgrade - No issue
  5. Upgraded php to 8.1 No issue: Upgrade successful. User is able to access Magento admin and UI. Kindly elaborate the steps/ missing configuration details to reproduce the issue. Thank you.
mrtuvn commented 2 years ago

you need install monolog v2.7.0 to able see problem

engcom-November commented 2 years ago

Thanks for the update @mrtuvn However, monolog is not part of https://github.com/magento/magento2 git repository. Community cannot able to provide fix for it in this repository. As per Magento devdocs, Magento uses Monolog by default. Monolog implemented as a preference for Psr\Log\LoggerInterface in the Magento application di.xml Kindly refer this guide to use the same for logging. Otherwise all questions, issue reports and fix for them should be addressed to the corresponding extension owners(support) Thank you.

convenient commented 2 years ago

@engcom-November

The facts

Either way there is an action for magento here, when you build a version of latest magento from scratch you will pull in a monolog version incompatible with some magento code.

The maintainer of monolog thinks the implementations by magento in the data migration tool and the integration test infrastructure is, and i quote, "madness".

See https://github.com/Seldaek/monolog/issues/1684#issuecomment-1152874168 and also see https://github.com/magento/magento2/pull/35596#issuecomment-1153655914 where this issue affects the ability to run tests, the thing that ensures we are able to deliver robust software.

engcom-November commented 2 years ago

Verified the issue again by installing Magento 2.4.4 project-community-edition with PHP 8.1 but could not able to reproduce the issue with below steps performed:

  1. Installed Magento 2.4.4 Project Community edition with PHP 8.1.6
  2. Ran > composer require monolog/monolog:2.7.0 . (composer.json file got updated with "monolog/monolog": "2.7.0")
  3. Ran > composer update
  4. Ran > php bin/magento setup:upgrade No issue: Upgrade is successful. Kindly provide missing steps / configuration details to reproduce the issue. Thank you.
convenient commented 2 years ago

@engcom-November this issue i think you may also need to install https://github.com/magento/data-migration-tool#install-the-data-migration-tool

For my PR (#35596) to replicate you would need to run the integration tests but best to keep separate as they'd be separate codefixes :)

engcom-November commented 2 years ago

Verified the issue again on Magento 2.4.4 Project community edition with PHP 8.1.6 and the issue is reproducible on installing data-migration-tool. Error: PHP Fatal error: Declaration of Migration\Logger\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 /var/www/html/mg244/project-community-edition/vendor/magento/data-migration-tool/src/Migration/Logger/Logger.php on line 34

fvlasie commented 2 years ago

This also occurs with PHP 7.4...

Screenshot 2022-06-22 at 9 27 55 AM
fvlasie commented 2 years ago

Confirming that composer require monolog/monolog:2.6.0 fixed the issue.

github-jira-sync-bot commented 2 years ago

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-5973 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 years ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

timoffmax commented 2 years ago

Also reproducible when you run integration tests.

convenient commented 2 years ago

https://github.com/Seldaek/monolog/commit/3cba75ec0926eec177a4a2cd6c977ecddd0fc7c1

Mark Logger https://github.com/Final to discourage extension

Updating to use a handler seems like the right thing to do.

damienwebdev commented 2 years ago

Just a notification that a further update to Monolog versions occurred ~3 hours ago - 2.8.0 https://github.com/Seldaek/monolog/releases/tag/2.8.0.

I had code like:

composer require monolog/monolog:"!=2.7.0" --no-update

Which I now changed to:

composer require monolog/monolog:"<2.7.0" --no-update
ihor-sviziev commented 2 years ago

Looks like in Magento 2.4.5 we have a fix for this issue https://github.com/magento/magento2/commit/360fd1ba9d6e67185b7fbd3e00223cd948bb896e

hostep commented 2 years ago

The full AC-3556 fix is here: https://github.com/magento/magento2/commit/b2bfd0562c3ea5708fb836347404ce38b57040c4

Unfortunately the fix seems just like a workaround, because this problem might happen again in the future. It's probably wiser if Adobe listens to the recommendations of the author of the monolog library who suggests a more future proofed way to fix this.

convenient commented 2 years ago

Agreed @hostep

I did try and have some conversation about this back in June but was ignored.

https://github.com/magento/magento2/pull/35596#issuecomment-1153655914

My workaround was then taken in any case 🙃

Nuranto commented 2 years ago

Hi there,

I think you missed this one : vendor/magento/data-migration-tool/src/Migration/Logger/Logger.php

engcom-Hotel commented 2 years ago

Hello,

As I can see this issue got fixed by the internal team Related commits: https://github.com/magento/magento2/commit/b2bfd0562c3ea5708fb836347404ce38b57040c4

Hence closing the issue.

Thanks