From 55855ebfb441379b02f366fce09426f0e493f70e Mon Sep 17 00:00:00 2001 From: Divyajose <75604843+divya-intelli@users.noreply.github.com> Date: Tue, 9 May 2023 12:42:35 +0530 Subject: [PATCH] Fix for failed update when apiProduct field is disabled (#429) * Fix for failed update when apiProduct field is disabled --- apigee_m10n.install | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apigee_m10n.install b/apigee_m10n.install index 33827af0..ec530b71 100644 --- a/apigee_m10n.install +++ b/apigee_m10n.install @@ -160,11 +160,12 @@ function apigee_m10n_update_8203(&$sandbox) { $display_repository = \Drupal::service('entity_display.repository'); // Get the default view display for xrateplan. $view_display = $display_repository->getViewDisplay('xrate_plan', 'xrate_plan', 'default'); - $component = $view_display->getComponent('apiProduct'); - $settings = [ - 'link' => false, - ]; - $view_display->setComponent('apiProduct', ['settings' => $settings,] + $component)->save(); + if ($component = $view_display->getComponent('apiProduct')) { + $settings = [ + 'link' => false, + ]; + $view_display->setComponent('apiProduct', ['settings' => $settings,] + $component)->save(); + } if (Drupal::moduleHandler()->moduleExists('user')) { user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['view xproduct']);