magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

TypeError: explode(): Argument #2 ($string) must be of type string, null given in /var/www/php/folder/vendor/magento/module-config/ViewModel/CountryFilter.php:46

Open pmonosolo opened this issue 3 years ago • 15 comments

Preconditions and environment

  • Magento version - 2.4.5 CE
  • Visit Stores -> Configuration and see error
  • Error reporting turned on
  • Page shows an error
  • PHP 8.1.9

Steps to reproduce

  1. Login into Admin Site
  2. Go to Stores->Configuration

Expected result

Configuration page visible

Actual result

Error is thrown:

TypeError: explode(): Argument #2 ($string) must be of type string, null given in /var/www/php/folder/vendor/magento/module-config/ViewModel/CountryFilter.php:46 Stack trace: #0 /var/www/php/folder/vendor/magento/module-config/ViewModel/CountryFilter.php(46): explode(',', NULL) #1 /var/www/php/folder/vendor/magento/module-config/view/adminhtml/templates/system/config/js.phtml(81): Magento\Config\ViewModel\CountryFilter->getEuCountryList() #2 /var/www/php/folder/vendor/magento/framework/View/TemplateEngine/Php.php(71): include('/var/www/php/mo...') #3 /var/www/php/folder/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Backend\Block\Template), '/var/www/php/mo...', Array) #4 /var/www/php/folder/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\TemplateEngine\Php\Interceptor->___callParent('render', Array) #5 /var/www/php/folder/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\TemplateEngine\Php\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Backend\Block\Template), '/var/www/php/mo...', Array) #6 /var/www/php/folder/generated/code/Magento/Framework/View/TemplateEngine/Php/Interceptor.php(23): Magento\Framework\View\TemplateEngine\Php\Interceptor->___callPlugins('render', Array, Array) #7 /var/www/php/folder/vendor/magento/framework/View/Element/Template.php(263): Magento\Framework\View\TemplateEngine\Php\Interceptor->render(Object(Magento\Backend\Block\Template), '/var/www/php/mo...', Array) #8 /var/www/php/folder/vendor/magento/framework/View/Element/Template.php(293): Magento\Framework\View\Element\Template->fetchView('/var/www/php/mo...') #9 /var/www/php/folder/vendor/magento/module-backend/Block/Template.php(141): Magento\Framework\View\Element\Template->_toHtml() #10 /var/www/php/folder/vendor/magento/framework/View/Element/AbstractBlock.php(1095): Magento\Backend\Block\Template->_toHtml() #11 /var/www/php/folder/vendor/magento/framework/View/Element/AbstractBlock.php(1099): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element{closure}() #12 /var/www/php/folder/vendor/magento/framework/View/Element/AbstractBlock.php(660): Magento\Framework\View\Element\AbstractBlock->_loadCache() #13 /var/www/php/folder/vendor/magento/framework/View/Layout.php(578): Magento\Framework\View\Element\AbstractBlock->toHtml() #14 /var/www/php/folder/vendor/magento/framework/View/Layout.php(555): Magento\Framework\View\Layout->_renderBlock('js.system_confi...') #15 /var/www/php/folder/generated/code/Magento/Framework/View/Layout/Interceptor.php(41): Magento\Framework\View\Layout->renderNonCachedElement('js.system_confi...') #16 /var/www/php/folder/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('js.system_confi...') #17 /var/www/php/folder/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement('js.system_confi...', false) #18 /var/www/php/folder/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer('js', false) #19 /var/www/php/folder/generated/code/Magento/Framework/View/Layout/Interceptor.php(41): Magento\Framework\View\Layout->renderNonCachedElement('js') #20 /var/www/php/folder/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('js') #21 /var/www/php/folder/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement('js', false) #22 /var/www/php/folder/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer('page.wrapper', false) #23 /var/www/php/folder/generated/code/Magento/Framework/View/Layout/Interceptor.php(41): Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper') #24 /var/www/php/folder/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('page.wrapper') #25 /var/www/php/folder/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement('page.wrapper', false) #26 /var/www/php/folder/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer('backend.page', false) #27 /var/www/php/folder/generated/code/Magento/Framework/View/Layout/Interceptor.php(41): Magento\Framework\View\Layout->renderNonCachedElement('backend.page') #28 /var/www/php/folder/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('backend.page') #29 /var/www/php/folder/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout->renderElement('backend.page', false) #30 /var/www/php/folder/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer('root', false) #31 /var/www/php/folder/generated/code/Magento/Framework/View/Layout/Interceptor.php(41): Magento\Framework\View\Layout->renderNonCachedElement('root') #32 /var/www/php/folder/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('root') #33 /var/www/php/folder/vendor/magento/framework/View/Layout.php(975): Magento\Framework\View\Layout->renderElement('root') #34 /var/www/php/folder/generated/code/Magento/Framework/View/Layout/Interceptor.php(50): Magento\Framework\View\Layout->getOutput() #35 /var/www/php/folder/vendor/magento/framework/View/Result/Page.php(260): Magento\Framework\View\Layout\Interceptor->getOutput() #36 /var/www/php/folder/vendor/magento/framework/View/Result/Layout.php(171): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor)) #37 /var/www/php/folder/generated/code/Magento/Backend/Model/View/Result/Page/Interceptor.php(32): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor)) #38 /var/www/php/folder/vendor/magento/framework/App/Http.php(120): Magento\Backend\Model\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor)) #39 /var/www/php/folder/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch() #40 /var/www/php/folder/pub/index.php(30): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor)) #41 {main}

Additional information

No response

Release note

No response

Triage and priority

  • [X] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [ ] 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”.

pmonosolo avatar Aug 09 '22 23:08 pmonosolo

Hi @pmonosolo. 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 Aug 09 '22 23:08 m2-assistant[bot]

The code responsible is this:

image

I wonder if the list was not generated or something during the upgrade?

I've tried flushing cache and disabling it completely.

pmonosolo avatar Aug 09 '22 23:08 pmonosolo

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 Aug 10 '22 06:08 m2-assistant[bot]

Running 2.4.5 on PHP 8.1 here and not having this issue. Perhaps some external module is altering this list?

jorgb90 avatar Aug 10 '22 13:08 jorgb90

Running 2.4.5 on PHP 8.1 here and not having this issue. Perhaps some external module is altering this list?

Hmmm, not sure yet. Just starting to dig into this again.

So far I have: rm -rf vendor/*

Then upgraded composer to v2 and reinstalled everything. Still getting the same error.

Found mentions of CountryFilter in two plugins:

vendor/webshopapps/module-matrixrate/src/Model/ResourceModel/Carrier/Matrixrate/Collection.php:    public function setCountryFilter($countryId)
vendor/mageside/canada-post-shipping/Model/Source/Province.php:        $this->addCountryFilter('CA');
vendor/mageside/canada-post-shipping/Model/Service/Postoffice.php:            $collection->addCountryFilter('CA')->load();

Going to try to go around them or deinstall. Will report back.

pmonosolo avatar Aug 10 '22 17:08 pmonosolo

Disabling / removing those two plugins did not work.

I assume this is a data problem - something broke when initial upgrade script ran (did not finish successfully on first try).

Going to try uploading new backup of DB and re-running the upgrade command.

pmonosolo avatar Aug 10 '22 19:08 pmonosolo

Could it be related to: https://github.com/magento/magento2/issues/35875 ?

pmonosolo avatar Aug 10 '22 19:08 pmonosolo

Hmmm same error after redoing upgrade command on new DB backup.

Must be something else.

Tried this:

image

And the page pulled up right away.

pmonosolo avatar Aug 10 '22 19:08 pmonosolo

Checked the DB:

image

Looks like the values are empty. Are they supposed to be any other way?

On Magento 2.4.3 site in production now, these values are unchecked (no countries chosen):

image

And "Use system value" is unchecked.

pmonosolo avatar Aug 10 '22 19:08 pmonosolo

After doing this:

image

Then going to General -> Countries -> European Union Countries -> Clicking "Use system value"

Then undoing the code back to initial state:

image

The page now shows up correctly:

image

Then when I rerun the MySQL query for same field:

image

It shows 0 results.

So it must be that when no EU countries are selected, it created the field with NULL, but then NULL is not accepted by the code.

pmonosolo avatar Aug 10 '22 20:08 pmonosolo

I think this was a bug somewhere in 2.4.3, or in the earlier version of Magento 2.3.3 which the site went through that the values were not defaulted when you uncheck them and uncheck "Use system value".

Now on 2.4.5 when you uncheck the "Use System Value" it defaults the fields to:

image

If you uncheck all those countries and save again, it puts them back in.

UPDATE: Yes, confirmed 2.4.3 does not default the values, it nulls them when "Use System Value" is unchecked.

When 2.4.5 upgrade happens it expects the value not to be NULL, thats where the issue is coming from.

pmonosolo avatar Aug 10 '22 20:08 pmonosolo

Hi @pmonosolo , Thank you for reporting and collaboration. Verified the issue by upgrading from 2.4.3 to 2.4.5 in production mode but could not able to reproduce the issue. Kindly elaborate the steps / configuration details or any other modules enabled if any is causing the issue. Thank you.

engcom-November avatar Aug 11 '22 11:08 engcom-November

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

github-jira-sync-bot avatar Aug 11 '22 14:08 github-jira-sync-bot

:white_check_mark: Confirmed by @sidolov. Thank you for verifying the issue.
Issue Available: @sidolov, 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 Aug 11 '22 14:08 m2-assistant[bot]

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

github-jira-sync-bot avatar Aug 11 '22 15:08 github-jira-sync-bot

It was fixed in commit https://github.com/magento/magento2/commit/29f065842df8485c6300c4056eac134dfaa906c6

rogerdz avatar Sep 14 '22 07:09 rogerdz

Hello,

As I can see this issue got fixed in the scope of the internal Jira ticket AC-6385 by the internal team Related commits: https://github.com/magento/magento2/search?q=AC-6385&type=commits

Based on the Jira ticket, the target version is 2.4.6.

Thanks

engcom-Hotel avatar Sep 14 '22 11:09 engcom-Hotel

@engcom-Hotel I updated my magento 2.4.4 to 2.4.6-p3 and this error persists. I checked the files within the latest commit AC-6385 and they are present in version 2.4.6-p3. Is there any provision for merging this commit?

davirs avatar Nov 21 '23 15:11 davirs

Sure @davirs, let us check, we will get back to you.

engcom-Hotel avatar Nov 22 '23 07:11 engcom-Hotel

@engcom-Hotel Same here after update from 2.4.2 to 2.4.6-p3

webcreative24 avatar Mar 11 '24 20:03 webcreative24

Here is the solution: find in your DB SELECT * FROM core_config_data WHERE path = 'general' and then remove these records from the DB. clear cache - enjoy

webcreative24 avatar Mar 11 '24 20:03 webcreative24

And 2.4.7 same issue. Its not soo hard to fix it. Magento Dev needs to be more faster to fix that problems.

ingmarnet avatar Apr 11 '24 13:04 ingmarnet