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.57k stars 9.32k forks source link

PHP Fatal error in cron job magento_giftcardaccount_update_states #35523

Open engcom-November opened 2 years ago

engcom-November commented 2 years ago

@fredden Reopening this issue reported by you as the old one is transferred to partnersee-repo https://github.com/magento/partners-magento2ee/issues/681

Preconditions and environment

  1. Tested with Adobe Commerce v2.4.3-p1. Other versions are also affected.
  2. Create a new Website and associated Store but no store view
  3. cron enabled

Steps to reproduce

  1. Created new website and Store (Stores - All Stores) but no store view
  2. Reindex and clear cache
  3. Inserted record in cron_schedule table with job_code "jmagento_giftcardaccount_update_states"
  4. ran cron job from CLI:
  5. php bin/magento cron:run --group magento_giftcardaccount_update_states; Output: Job ran successfully without any errors
  6. Verify message in cron_schedule table:

Note: Other records inserted gives no errors. Note: If Store view is created for the new store, error is not displayed on performing above steps.

Expected result

No PHP error should be displayed.

Actual result

PHP Fatal error is thrown.

app@686b4c600be7:~/html$ vendor/bin/n98-magerun2 sys:cron:run magento_giftcardaccount_update_states Run Magento\GiftCardAccount\Model\Cron::updateStates PHP Fatal error: Uncaught Error: Call to a member function getId() on null in /var/www/html/vendor/magento/module-gift-card-account/Model/Cron.php:91 Stack trace:

0 phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/System/Cron/RunCommand.php(66): Magento\GiftCardAccount\Model\Cron->updateStates(Object(Magento\Cron\Model\Schedule\Interceptor))

magento/magento2#1 /var/www/html/vendor/symfony/console/Command/Command.php(255): N98\Magento\Command\System\Cron\RunCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) magento/magento2#2 phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/AbstractMagentoCommand.php(363): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) magento/magento2#3 phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Application.php(1027): N98\Magento\Command\AbstractMagentoCommand->run(Object(S in /var/www/html/vendor/magento/module-gift-card-account/Model/Cron.php on line 91

Fatal error: Uncaught Error: Call to a member function getId() on null in /var/www/html/vendor/magento/module-gift-card-account/Model/Cron.php:91 Stack trace:

0 phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/System/Cron/RunCommand.php(66): Magento\GiftCardAccount\Model\Cron->updateStates(Object(Magento\Cron\Model\Schedule\Interceptor))

magento/magento2#1 /var/www/html/vendor/symfony/console/Command/Command.php(255): N98\Magento\Command\System\Cron\RunCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) magento/magento2#2 phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/src/N98/Magento/Command/AbstractMagentoCommand.php(363): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) magento/magento2#3 phar:///var/www/html/vendor/n98/magerun2-dist/n98-magerun2/vendor/symfony/console/Application.php(1027): N98\Magento\Command\AbstractMagentoCommand->run(Object(S in /var/www/html/vendor/magento/module-gift-card-account/Model/Cron.php on line 91 app@686b4c600be7:~/html$

Additional information

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @engcom-November. 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

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

Created new issue as this issue got moved to partners-ee repo: https://github.com/magento/partners-magento2ee/issues/681. Hence confirming the issue here.

github-jira-sync-bot commented 2 years ago

:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-3024

fredden commented 2 years ago

@engcom-November can the original issue not be transferred back here? It looks like the formatting of the issue has been lost in the copy/paste.

fredden commented 2 years ago

@engcom-November please can you fix the formatting of this issue to match the original I submitted.

engcom-Delta commented 1 week ago

Hi @fredden ,

Thanks for your reporting and collaboration. We have re-verified the issue in Latest 2.4-develop instance , but we are unable to reproduce the issue. Kindly refer the screenshots.

Steps to reproduce

  1. Created new website and Store (Stores - All Stores) but no store view
  2. Reindex and clear cache
  3. Inserted record in cron_schedule table with job_code "jmagento_giftcardaccount_update_states"
  4. ran cron job from CLI:
  5. php bin/magento cron:run --group magento_giftcardaccount_update_states;
  6. Output: Job ran successfully without any errors Expected result No PHP error should be displayed. image

Can you please re-verify and confirm if you are still facing the issue. Thanks.

fredden commented 1 week ago

@engcom-Delta did the job actually run? I see there is a rogue 'j' at the start of the job name in the instructions that you posted. Can you try with n98-magerun2 instead? (The steps for this are much simpler.) Are you running with Adobe Commerce or Magento Open Source? (See the pre conditions.) Do you have a store without a store view?

Can you please re-verify and confirm if you are still facing the issue.

I no longer have access to Adobe Commerce. If you wish to furnish me with a license then I can run this test.