Skip to content
Snippets Groups Projects
Commit bdd38237 authored by Romanos Dodopoulos's avatar Romanos Dodopoulos
Browse files

Remove centrally managed module/theme from update

Implement hook_update_projects_alter() to remove all centrally managed
modules and themes from the Update manager. Those which are located
under ^sites/all/.

The hook doesn't work for modules whose module name does not match the
project name. A workaround would be far more extended than these few
lines of code. Another workaround would be to remove them individually
which wouldn't be extensible. So the best option is to follow a policy
to always match the module and project names (see
https://www.drupal.org/node/2821041 and DRUPAL-76)

The list_themes() function makes the unset operation easier for themes
because it returns a list of objects with all the related information
(i.e. path and project name). Still there was an error dues to a
single theme (cern_default) that isn't related to a project but this
was fixed with an if condition.

Related to DRUPAL-65.
parent 60764f10
No related branches found
No related tags found
No related merge requests found
name = CERN Integration name = CERN Integration
package = CERN package = CERN
description = Provides CERN site integration for Drupal. description = Provides CERN site integration for Drupal.
version = "7.X-1.8" version = "7.X-1.9"
core = 7.x core = 7.x
dependencies[] = shib_auth dependencies[] = shib_auth
...@@ -9,6 +9,6 @@ files[] = cern_integration.module ...@@ -9,6 +9,6 @@ files[] = cern_integration.module
files[] = cern_integration.install files[] = cern_integration.install
project = "cern_integration" project = "cern_integration"
datestamp = "1455099515" datestamp = "1493373769"
required = TRUE required = TRUE
...@@ -555,3 +555,26 @@ function cern_integration_form_domain_301_redirect_admin_form_alter (&$form, &$ ...@@ -555,3 +555,26 @@ 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.
*/
function cern_integration_update_projects_alter(&$projects) {
// Remove all centrally managed modules.
foreach (module_list() as $module) {
if (preg_match('/^sites\/all\/modules\//', drupal_get_path('module', $module))) {
// This works only if the module name matches the project name.
unset($projects[$module]);
}
}
// Remove all centrally managed themes.
foreach (list_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($projects[$theme_obj->info['project']]);
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment