diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc index 26f3c9b..e131d99 100644 --- a/core/modules/locale/locale.compare.inc +++ b/core/modules/locale/locale.compare.inc @@ -62,11 +62,14 @@ function locale_translation_build_projects() { foreach ($projects as $name => $data) { if (isset($project_updates[$name]['releases']) && $project_updates[$name]['project_status'] != 'not-fetched') { // Find out if a dev version is installed. - if (preg_match("/^[0-9]+\.x-([0-9]+)\..*-dev$/", $data['info']['version'], $matches)) { + if (preg_match("/^\d+\.x-(\d+)\..*-dev$/", $data['info']['version'], $matches) || + preg_match("/^(\d+)\.\d+\.\d+.*-dev$/", $data['info']['version'], $matches)) { // Find a suitable release to use as alternative translation. foreach ($project_updates[$name]['releases'] as $project_release) { // The first release with the same major release number which is not a // dev release is the one. Releases are sorted the most recent first. + // For example the major release number for a contrib module + // 8.x-2.x-dev is "2", for core 8.1.0-dev is "8". // @todo http://drupal.org/node/1774024 Make a helper function. if ($project_release['version_major'] == $matches[1] && (!isset($project_release['version_extra']) || $project_release['version_extra'] != 'dev')) { diff --git a/core/modules/locale/src/Tests/LocaleUpdateNotDevTest.php b/core/modules/locale/src/Tests/LocaleUpdateNotDevTest.php new file mode 100644 index 0000000..bd028a5 --- /dev/null +++ b/core/modules/locale/src/Tests/LocaleUpdateNotDevTest.php @@ -0,0 +1,79 @@ +drupalCreateUser(array('administer modules', 'administer languages', 'access administration pages', 'translate interface')); + $this->drupalLogin($admin_user); + $this->drupalPostForm('admin/config/regional/language/add', array('predefined_langcode' => 'hu'), t('Add language')); + + // Set available Drupal releases for test. + $available = array( + 'title' => 'Drupal core', + 'short_name' => 'drupal', + 'type' => 'project_core', + 'api_version' => '8.x', + 'project_status' => 'unsupported', + 'link' => 'https://www.drupal.org/project/drupal', + 'terms' => '', + 'releases' => array( + '8.0.0-alpha110' => array( + 'name' => 'drupal 8.0.0-alpha110', + 'version' => '8.0.0-alpha110', + 'tag' => '8.0.0-alpha110', + 'version_major' => '8', + 'version_minor' => '0', + 'version_patch' => '0', + 'version_extra' => 'alpha110', + 'status' => 'published', + 'release_link' => 'https://www.drupal.org/node/2316617', + 'download_link' => 'http://ftp.drupal.org/files/projects/drupal-8.0.0-alpha110.tar.gz', + 'date' => '1407344628', + 'mdhash' => '9d71afdd0ce541f2ff5ca2fbbca00df7', + 'filesize' => '9172832', + 'files' => '', + 'terms' => array(), + ), + '8.0.0-alpha100' => array( + 'name' => 'drupal 8.0.0-alpha100', + 'version' => '8.0.0-alpha100', + 'tag' => '8.0.0-alpha100', + 'version_major' => '8', + 'version_minor' => '0', + 'version_patch' => '0', + 'version_extra' => 'alpha100', + 'status' => 'published', + 'release_link' => 'https://www.drupal.org/node/2316617', + 'download_link' => 'http://ftp.drupal.org/files/projects/drupal-8.0.0-alpha100.tar.gz', + 'date' => '1407344628', + 'mdhash' => '9d71afdd0ce541f2ff5ca2fbbca00df7', + 'filesize' => '9172832', + 'files' => '', + 'terms' => array(), + ), + ), + ); + $available['last_fetch'] = time(); + \Drupal::keyValueExpirable('update_available_releases')->setWithExpire('drupal', $available, 10); + $projects = locale_translation_build_projects(); + $this->verbose($projects['drupal']->info['version']); + $this->assertEqual($projects['drupal']->info['version'], '8.0.0-alpha110', 'The first release with the same major release number which is not a dev release.'); + } +} diff --git a/core/modules/locale/tests/modules/locale_test_notdev/locale_test_notdev.info.yml b/core/modules/locale/tests/modules/locale_test_notdev/locale_test_notdev.info.yml new file mode 100644 index 0000000..952fb2d --- /dev/null +++ b/core/modules/locale/tests/modules/locale_test_notdev/locale_test_notdev.info.yml @@ -0,0 +1,7 @@ +name: 'Locale Test NotDev' +type: module +description: 'The first release with the same major release number which is not a dev release.' +package: Testing +version: VERSION +core: 8.x +hidden: true diff --git a/core/modules/locale/tests/modules/locale_test_notdev/locale_test_notdev.module b/core/modules/locale/tests/modules/locale_test_notdev/locale_test_notdev.module new file mode 100644 index 0000000..2739b6a --- /dev/null +++ b/core/modules/locale/tests/modules/locale_test_notdev/locale_test_notdev.module @@ -0,0 +1,20 @@ +