Quantcast
Viewing all articles
Browse latest Browse all 294613

drupal_check_profile throws error if hook_requirements returns null

When drupal_check_profile() checks installation requirements, it doesn't check the type of the values returned from hook_requirements implementations before sending them to array_merge(). This results in an error if an implementation doesn't return a value for the 'install' phase.

e.g.

function mymodule_requirements($phase) {
  if ($phase !== 'runtime') {
    return;
  }
  
  return [
    // ...runtime requirements...
  ];
}

The current check:

if (function_exists($function)) {
  $requirements = array_merge($requirements, $function('install'));
}

For comparison, ModuleHandler::invokeAll() only merges if isset() passes:

if (isset($result) && is_array($result)) {
  $return = NestedArray::mergeDeep($return, $result);
}
elseif (isset($result)) {
  $return[] = $result;
}

Viewing all articles
Browse latest Browse all 294613

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>