From f2266dbc0805b880bc57b1186dd6ef5730264f94 Mon Sep 17 00:00:00 2001 From: Romanos Dodopoulos <romanos.dodopoulos@cern.ch> Date: Mon, 8 May 2017 17:07:43 +0200 Subject: [PATCH] Remove subthemes of an infra theme from update Remove all subthemes of a centrally managed theme from the Update manager. This prevents an Undefined index Notice when a locally installed theme has a centrally managed one as base (e.g., CERN Overwrite Theme). See DRUPAL-65 --- cern_integration.info | 2 +- cern_integration.module | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cern_integration.info b/cern_integration.info index 3abc8f6..5f204d0 100644 --- a/cern_integration.info +++ b/cern_integration.info @@ -1,7 +1,7 @@ name = CERN Integration package = CERN description = Provides CERN site integration for Drupal. -version = "7.X-1.9" +version = "7.X-1.10" core = 7.x dependencies[] = shib_auth diff --git a/cern_integration.module b/cern_integration.module index 7cee31a..541ef93 100644 --- a/cern_integration.module +++ b/cern_integration.module @@ -557,7 +557,9 @@ function cern_integration_form_domain_301_redirect_admin_form_alter (&$form, &$ /** * Implements hook_update_projects_alter(). - * Remove all centrally managed modules and themes from the Update manager. + * Remove all centrally managed modules and themes from the Update manager. In addition, remove + * all local themes with a centrally managed as base. Because the update manager tries to check + * for an update of the base which causes a 'Undefined index' notice. */ function cern_integration_update_projects_alter(&$projects) { // Remove all centrally managed modules. @@ -567,12 +569,24 @@ function cern_integration_update_projects_alter(&$projects) { unset($projects[$module]); } } - // Remove all centrally managed themes. - foreach (list_themes() as $theme_obj){ + // Remove all centrally managed themes and their subthemes. + $array_themes = list_themes(); + foreach ($array_themes as $theme_obj) { // Check if there is a project for that theme. // This is normally true but not always. if (isset($theme_obj->info['project'])) { if (preg_match('/^sites\/all\/themes\//', $theme_obj->filename)) { + // Unset all subthemes. + if (property_exists($theme_obj, 'sub_themes')) { + foreach ($theme_obj->sub_themes as $sub_theme_folder_name => $sub_theme_name) { + // Since we can use neither the folder nor the theme name, get the project name if it is still set. + if (isset($array_themes[$sub_theme_folder_name]->info['project'])) { + $sub_theme_project_name = $array_themes[$sub_theme_folder_name]->info['project']; + unset($projects[$sub_theme_project_name]); + } + } + } + // Unset the centrally managed theme. unset($projects[$theme_obj->info['project']]); } } -- GitLab