magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Monolog issue

Open Nuranto opened this issue 2 years ago • 21 comments

Preconditions and environment

  • Magento version 2.4.4
  • PHP8.1
  • Install data-migration-tool
  • Monolog 2.7.0

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

  • [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [X] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Nuranto avatar Jun 10 '22 08:06 Nuranto

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

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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.


:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

: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

m2-assistant[bot] avatar Jun 10 '22 08:06 m2-assistant[bot]

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

mrtuvn avatar Jun 10 '22 08:06 mrtuvn

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

convenient avatar Jun 10 '22 14:06 convenient

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:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar Jun 15 '22 11:06 m2-assistant[bot]

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.

engcom-November avatar Jun 16 '22 16:06 engcom-November

you need install monolog v2.7.0 to able see problem

mrtuvn avatar Jun 16 '22 23:06 mrtuvn

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.

engcom-November avatar Jun 17 '22 12:06 engcom-November

@engcom-November

The facts

  • Magento require version ^2.6 of monolog, which means that 2.7.0 is the highest version that is installed when you composer create project of magento https://github.com/magento/magento2/blob/28c1f28a2552de69158b40d1eaf84e45430c16f9/composer.json#L69
  • This means magento either needs to say <=2.7.0 for their monolog requirement, or fix their application code to be compatible.

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.

convenient avatar Jun 17 '22 12:06 convenient

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.

engcom-November avatar Jun 17 '22 13:06 engcom-November

@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 :)

convenient avatar Jun 17 '22 13:06 convenient

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

engcom-November avatar Jun 20 '22 12:06 engcom-November

This also occurs with PHP 7.4... Screenshot 2022-06-22 at 9 27 55 AM

fvlasie avatar Jun 22 '22 16:06 fvlasie

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

fvlasie avatar Jun 22 '22 16:06 fvlasie

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

github-jira-sync-bot avatar Jul 15 '22 06:07 github-jira-sync-bot

: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.

m2-assistant[bot] avatar Jul 15 '22 06:07 m2-assistant[bot]

Also reproducible when you run integration tests.

timoffmax avatar Jul 19 '22 18:07 timoffmax

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.

convenient avatar Jul 22 '22 11:07 convenient

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

damienwebdev avatar Jul 24 '22 14:07 damienwebdev

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

ihor-sviziev avatar Aug 09 '22 21:08 ihor-sviziev

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.

hostep avatar Aug 11 '22 17:08 hostep

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 🙃

convenient avatar Aug 11 '22 17:08 convenient

Hi there,

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

Nuranto avatar Aug 29 '22 07:08 Nuranto

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

engcom-Hotel avatar Oct 10 '22 08:10 engcom-Hotel