1 installer.module installer_verify_update_archive($project, $archive_file, $directory)

Implements hook_verify_update_archive().

First, we ensure that the archive isn't a copy of Backdrop core, which the update manager does not yet support. See http://drupal.org/node/606592

Then, we make sure that at least one module included in the archive file has an .info file which claims that the code is compatible with the current version of Backdrop core.

See also

backdrop_system_listing()

_system_rebuild_module_data()

File

core/modules/installer/installer.module, line 223
Handles installation and updates of contributed projects.

Code

function installer_verify_update_archive($project, $archive_file, $directory) {
  $errors = array();

  // Parse all the .info files and make sure at least one is compatible with
  // this version of Backdrop core. If one is compatible, then the project as a
  // whole is considered compatible (since, for example, the project may ship
  // with some out-of-date modules that are not necessary for its overall
  // functionality).
  $compatible_project = FALSE;
  $incompatible = array();
  $files = file_scan_directory("$directory/$project", '/^' . BACKDROP_PHP_FUNCTION_PATTERN . '\.info$/', array('key' => 'name', 'min_depth' => 0));
  foreach ($files as $key => $file) {
    // Get the .info file for the module, theme or layout this file belongs to.
    $info = backdrop_parse_info_file($file->uri);

    // If the module, theme or layout is incompatible with Backdrop core, set an error.
    if (empty($info['backdrop']) || $info['backdrop'] != BACKDROP_CORE_COMPATIBILITY) {
      $incompatible[] = !empty($info['name']) ? $info['name'] : t('Unknown');
    }
    else {
      $compatible_project = TRUE;
      break;
    }
  }

  if (empty($files)) {
    $errors[] = t('%archive_file does not contain any .info files.', array('%archive_file' => backdrop_basename($archive_file)));
  }
  elseif (!$compatible_project) {
    $errors[] = format_plural(
    count($incompatible), 
    '%archive_file contains a version of %names that is not compatible with Backdrop !version.', 
    '%archive_file contains versions of modules or themes that are not compatible with Backdrop !version: %names', 
    array('!version' => BACKDROP_CORE_COMPATIBILITY, '%archive_file' => backdrop_basename($archive_file), '%names' => implode(', ', $incompatible))
    );
  }

  return $errors;
}