Invalid argument supplied for foreach() in Drupal\views\Plugin\views\display\DisplayPluginBase->destroy().
I am getting warning when edit and delete address in addressbook. Sometime it gives error on address list page also. I have checked that the value passes to foreach() inside destroy() in view module is sometime string and then it gives warning.

Comments

supriya1992 created an issue. See original summary.

supriya1992’s picture

StatusFileSize
new929 bytes

I have created a patch and it is working fine.

supriya1992’s picture

Status: Active » Needs review
supriya1992’s picture

Sorry for this wrong patch. I am uploading correct one.

supriya1992’s picture

StatusFileSize
new807 bytes
yepa’s picture

Thanks for your work @supriya1992 ;)

I've the same error on a page which contains a view:

Error: Call to undefined method stdClass::destroy() in Drupal\views\Plugin\views\display\DisplayPluginBase->destroy() (line 219 of /var/www/html/web/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php) 
#0 /var/www/html/web/core/modules/views/src/DisplayPluginCollection.php(62): Drupal\views\Plugin\views\display\DisplayPluginBase->destroy() 
#1 /var/www/html/web/core/modules/views/src/DisplayPluginCollection.php(45): Drupal\views\DisplayPluginCollection->clear() 
#2 [internal function]: Drupal\views\DisplayPluginCollection->__destruct() 
#3 /var/www/html/web/core/lib/Drupal/Core/Cache/ApcuBackend.php(90): apcu_fetch(Array) 
#4 /var/www/html/web/core/lib/Drupal/Core/Cache/ChainedFastBackend.php(141): Drupal\Core\Cache\ApcuBackend->getMultiple(Array, false) ...

I've found how to reproduce:
- We have a view of nodes
- If we add a field: "link to edit content" in the view, the bug occurs when loading the page with the view.

Here is the config diff:

----------------- config/sync/views.view.session_settings.yml -----------------
index 4532c67..bd99ae0 100644
@@ -1324,9 +1324,9 @@ display:
           empty_zero: false
           hide_alter_empty: false
           plugin_id: custom
-        edit_node:
-          id: edit_node
-          table: node_field_revision
+        edit_node_1:
+          id: edit_node_1
+          table: node
           field: edit_node
           relationship: none
           group_type: group

I've applied your patch but unfortunately I've always the fatal error.

yepa’s picture

StatusFileSize
new742 bytes

The patch attached seems working :)
Hope it helps.

supriya1992’s picture

"Views_DisplayPluginBase_destroy-3072159-7.patch" is not working for me because I am getting warning in line
foreach ($handlers as $id => $handler) {
where $handlers is not an array but still passing to foreach() loop.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

dhirendra.mishra’s picture

Version: 8.8.x-dev » 8.9.x-dev

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

cilefen’s picture

Category: Support request » Bug report
Status: Needs review » Needs work
Issue tags: -views, -core, - +Needs issue summary update, +Needs steps to reproduce

This is a bug report mis-categorized as a support request. It needs an issue summary update because Drupal doesn't ship with an address book. Some way to reproduce the bug with clear instructions are needed there.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.