Skip to content
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

[PHP 8.4] Warning: foreach() argument must be of type array|object, string given #4312

Open
ADDISON74 opened this issue Oct 25, 2024 · 0 comments
Labels
3rd-party Related to 3rd-party code or issues with customization bug

Comments

@ADDISON74
Copy link
Contributor

ADDISON74 commented Oct 25, 2024

This is the error message

Warning: foreach() argument must be of type array|object, string given in /var/www/html/app/design/adminhtml/default/default/template/widget/grid.phtml on line 163

            <?php if ($_multipleRows = $this->getMultipleRows($_item)):?>
                <?php foreach ($_multipleRows as $_i):?> <= LINE 163
                <tr>
                    <?php $i=0;foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
                        <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns-1?'last':'' ?>">
                            <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
                        </td>
                    <?php endforeach ?>
                </tr>
                <?php endforeach ?>
            <?php endif ?>

I am getting this error when running extension MageWorx SEO Suite Ultimate. Just accesss Backend > Catalog > SEO Breadcrumbs > Manage Breadcrumbs Priority for Category. Maybe other extensions could produce the same issue.

This must be solved using is_iterable() function

            <?php if ($_multipleRows = $this->getMultipleRows($_item)):?>
                <?php if (is_iterable($_multipleRows)): ?>
                    <?php foreach ($_multipleRows as $_i):?>
                <tr>
                    <?php $i=0;foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
                        <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns-1?'last':'' ?>">
                            <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
                        </td>
                    <?php endforeach ?>
                </tr>
                <?php endforeach ?>
                <?php endif ?>
@ADDISON74 ADDISON74 added the bug label Oct 25, 2024
@sreichel sreichel added the 3rd-party Related to 3rd-party code or issues with customization label Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd-party Related to 3rd-party code or issues with customization bug
Projects
None yet
Development

No branches or pull requests

2 participants