Projet

Général

Profil

Révision 503b3f7b

Ajouté par Assos Assos il y a environ 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/l10n_update/l10n_update.project.inc
25 25
/**
26 26
 * Rebuild project list
27 27
 *
28
 * @param $refresh
29
 *   TRUE: Refresh project list.
30
 *
28 31
 * @return array
32
 *   Array of project objects to be considered for translation update.
29 33
 */
30
function l10n_update_build_projects() {
34
function l10n_update_build_projects($refresh = FALSE) {
31 35
  module_load_include('inc', 'l10n_update');
32 36
  // Get all stored projects, including disabled ones
33
  $current = l10n_update_get_projects(NULL, TRUE);
37
  $current = l10n_update_get_projects($refresh, TRUE);
34 38
  // Now get the new project list, just enabled ones
35 39
  $projects = l10n_update_project_list();
36 40

  
......
47 51
    $projects_info = update_get_available(TRUE);
48 52
  }
49 53
  foreach ($projects as $name => $data) {
54

  
55
    // Force update fetch of project data in cases where Drupal's performance
56
    // optimized approach is missing out on some projects.
57
    // @see http://drupal.org/node/1671570#comment-6216090
58
    if (module_exists('update') && !isset($projects_info[$name])) {
59
      module_load_include('fetch.inc', 'update');
60
      _update_process_fetch_task($data);
61
      $available = _update_get_cached_available_releases();
62
      if (!empty($available[$name])) {
63
        $projects_info[$name] = $available[$name];
64
      }
65
    }
66

  
50 67
    if (isset($projects_info[$name]['releases']) && $projects_info[$name]['project_status'] != 'not-fetched') {
51 68
      // Find out if a dev version is installed.
52 69
      if (preg_match("/^[0-9]+\.x-([0-9]+)\..*-dev$/", $data['info']['version'], $matches)) {
53 70
        // Find a suitable release to use as alternative translation.
54 71
        foreach ($projects_info[$name]['releases'] as $project_release) {
55
          // The first release with the same major release number which is not 
72
          // The first release with the same major release number which is not
56 73
          // a dev release is the one. Releases are sorted the most recent first.
57 74
          if ($project_release['version_major'] == $matches[1] &&
58 75
              (!isset($project_release['version_extra']) || $project_release['version_extra'] != 'dev')) {
......
61 78
          }
62 79
        }
63 80
      }
64
      elseif ($name == "drupal" || preg_match("/HEAD/", $data['info']['version'], $matches)) {
65
        // Pick latest available release.
66
        $release = array_shift($projects_info[$name]['releases']);
67
      }
68

  
69 81
      if (!empty($release['version'])) {
70 82
        $data['info']['version'] = $release['version'];
71 83
      }
......
101 113
    }
102 114
    // Create / update project record
103 115
    $update = empty($current[$name]) ? array() : array('name');
104
    drupal_write_record('l10n_update_project', $project, $update);
116
    // @todo Use db_merge() to avoid problems with saving existing projects.
117
    try {
118
      drupal_write_record('l10n_update_project', $project, $update);
119
    }
120
    catch (Exception $e) {
121
      watchdog('l10n_update', 'Could not insert a project into the l10n_update_project table, possibly because it already exists.', NULL, WATCHDOG_INFO);
122
    }
105 123
    $projects[$name] = $project;
106 124
  }
107 125
  return $projects;
......
136 154
  $projects = array();
137 155

  
138 156
  // Get all current projects, including the recently installed.
139
  $current_projects = l10n_update_build_projects();
157
  $current_projects = l10n_update_build_projects(TRUE);
140 158
  // Collect project data of newly installed projects.
141 159
  foreach ($modules as $name) {
142 160
    if (isset($current_projects[$name])) {

Formats disponibles : Unified diff