Commit 1da7413f authored by osman's avatar osman

git commit -m 'Issue #3052771 by osman: Upgrade v1 -> v2: Warning: Invalid...

git commit -m 'Issue #3052771 by osman: Upgrade v1 -> v2: Warning: Invalid argument supplied for foreach()'
parent 4ec40014
......@@ -37,3 +37,30 @@ function lazy_requirements($phase) {
return $requirements;
}
/**
* Reset "disabled_paths" configuration to module default.
*/
function lazy_update_8201() {
$config = \Drupal::service('config.factory')->getEditable('lazy.settings');
if ($config->get('disabled_paths') === NULL) {
$config->set('disabled_paths', '/rss.xml');
return t('The new "disabled_paths" configuration is set to "/rss.xml" (default value).');
}
return NULL;
}
/**
* Reset "image_fields" configuration to module default.
*/
function lazy_update_8202() {
$config = \Drupal::service('config.factory')->getEditable('lazy.settings');
if ($config->get('image_fields') === TRUE) {
$config->set('image_fields', FALSE);
return t('<b>Action needed:</b> As of 8.x-2.x, image fields are now controlled individually. You need to manually update each image field to enable lazy-loading.');
}
return NULL;
}
......@@ -126,7 +126,7 @@ function lazy_is_enabled() {
$config = \Drupal::config('lazy.settings')->get();
$image_fields = $config['image_fields'];
if ($image_fields && !empty($image_fields)) {
if (is_array($image_fields)) {
foreach ($image_fields as $field_name => $bool_value) {
if ($bool_value) {
$status[$field_name] = TRUE;
......@@ -201,7 +201,7 @@ function lazy_field_formatter_settings_summary_alter(&$summary, $context) {
*/
function lazy_settings_update(array $image_fields) {
$current_image_fields = \Drupal::config('lazy.settings')->get('image_fields');
if (empty($current_image_fields)) {
if (!is_array($current_image_fields) || empty($current_image_fields)) {
$current_image_fields = [];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment