0

Whenever updating modules on an existing Drupal 7 site, I got lots of these error messages

Undefined index: php in system_requirements() (line 471 of xxxx/modules/system/system.install)

The code at that place reads

$files = system_rebuild_module_data();

...

foreach ($files as $module => $file) {
      // Ignore disabled modules and installation profiles.
      ...
      $php = $file->info['php'];
      if (version_compare($php, PHP_VERSION, '>')) {
        $requirements['php']['description'] .= $t('@name requires at least PHP @version.', array('@name' => $name, '@version' => $php));
        $requirements['php']['severity'] = REQUIREMENT_ERROR;
      }

It looks as if system_rebuild_module_data reads module .info files from the database (and stores it in drupal_static).

The 'php' entry in module .info files is optional, and indeed missing in most of my contrib modules.

Is this a bug in system.install, or am I missing something ?

The odd thing is, lots of people should be having this problem, and I can't find much online. Perhaps there is something wrong with my installation ?

1
  • 2
    If 'php' entry is missing in modules .info files, then this message is valid as a notice. Meanwhile those messages shouldn't bother you. There is nothing wrong with your installation. You can however report an issue in the contrib modules queue to include proper 'php' version in their .info file. Jan 22 at 16:15

1 Answer 1

1

When a module does not set a value for php in its .info file, Drupal uses DRUPAL_MINIMUM_PHP as default value. That default value is set by _system_rebuild_module_data() (which is called by system_rebuild_module_data(), which is called by system_requirements()).

// Set defaults for module info.
$defaults = array(
  'dependencies' => array(),
  'description' => '',
  'package' => 'Other',
  'version' => NULL,
  'php' => DRUPAL_MINIMUM_PHP,
  'files' => array(),
  'bootstrap' => 0,
);

// omissis

// Merge in defaults and save.
$modules[$key]->info = $module->info + $defaults;

Since the data returned from system_rebuild_module_data() is only cached in memory, I suppose there must be a module implementing hook_system_info_alter() that removes the php index from that data.

_system_rebuild_module_data() invokes those hooks with the following code.

// Invoke hook_system_info_alter() to give installed modules a chance to
// modify the data in the .info files if necessary.
$type = 'module';
drupal_alter('system_info', $modules[$key]->info, $modules[$key], $type);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.