Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I just upgraded the module to Version 2 via composer. Now I get the following error message:
"Warning: Invalid argument supplied for foreach() in lazy_is_enabled() (line 130 of modules/contrib/lazy/lazy.module)."
I am working on Windows 10, with Lando and Docker [18.06.1-ce-win73 (19507)]. Drupal is the newest Version 8.7.0.
Can you help me with this error?
If you need more information about my system or settings, please let me know!
Thank you!
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedjds23 created an issue. See original summary.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #3
dbgilbert CreditAttribution: dbgilbert at SEI Global Services Inc. commentedLooks like the issue is that the $image_fields config value is a boolean where the code expects an array. This makes sense given that the update to 2.0 changed the option from a single global switch to an array of switches for each image field. Seems like there should have been an update function in the .install file to handle the transition from 1.x to 2.0.
It seems relatively easy to resolve manually, however. If you find the lazy.settings config file (the one in your export directory, not the one in the module directory) you can manually change the image_fields value from true/false to an empty array [] and then run config import via drush. You may still see warnings but I was able to load pages at least, and access /admin/config/content/lazy to save a new config and pick up any other new config values.
Comment #4
osmanComment #6
osmanThis update fixes two issues which are experienced during an upgrade from 8.x-1.x to 8.x-2.x:
Previously the image fields option was a global switch for all image fields from all entities. As of 8.x-2.x, the image fields can be managed now individually in the image's format settings at the Manage Display pages.
Since there is now more flexibility, I opted not to enable lazy-loading for every single image field. You should enable the fields you need.
As of 8.x-2.x, there is also a new feature: Disabled Pages; where you can define all the paths that should not have lazy-loading enabled at all. The upgrade would omit the default value
/rss.xml
and keep the field empty.Comment #7
osman