Not sure if "version mismatch" is the best phrase for the title of this issue. Let me explain what I mean and please feel free to change the title is there is a better catch.

Sometimes there are dev releases for modules that have 'unusual' version tags, at least unusual to me. Example: the media_gallery dev release currently comes with version = "7.x-1.0-beta7+21-dev". The po-file on localize.drupal.org is named media_gallery-7.x-1.0-beta7.de.po and there is none available for the dev release.

Wouldn't it be nice and easy to use the string up to the + character in the version tag when searching for po files on the server? I've checked with other examples that this would in fact always work.

What do you think?

Comments

gábor hojtsy’s picture

The latest release which includes #1001554: Make it possible to fetch .po files for dev modules/core should have fixed this issue. Is it not working for you?

jurgenhaas’s picture

It looks like it downloads the file but according to the messages after the translation update it doesn't import those po files.

jurgenhaas’s picture

Oh, wait a minute. We probably got mislead here. It may well be that the po file is a little bit older and has been downloaded already some time ago and hence hasn't been imported this time. We are going to verify this with more tests and report back shortly.

sutharsan’s picture

Localization Update server only supplies po files for releases, not for dev-packages. If you have a dev release installed, Localization Update module falls back to the most recent release of the same branch. In your case the 7.x-1.0-beta7 translation is the fallback for 7.x-1.0-beta7+21-dev module version. This is by design behaviour. If the translation of the beta7 release got update, it will be imported by Localization Update. But it will only contain the string of the beta7 release. More recent string additions/changes in the module (between beta7 and beta7+21-dev) are unknown to the Localization Update server. And what is not there can not be imported.

jurgenhaas’s picture

Just done a fresh install and then went to admin/config/regional/translate/update finding the attached screen which shows that for media_gallery there are no updates found. Even if I refresh the information with the second button at the end of the form, this doesn't change.

jurgenhaas’s picture

BTW, I reported this against 1.0-beta3 and I wonder if the latest dev would be the done that had the resolution included?

sutharsan’s picture

beta3 does include this functionality. While reproducing your situation I got the same behaviour after downloading and enabling the dev-release of Media Gallery. No beta7 tranlation was indicated. It turned out that Update module caches its results. After visiting the available updates page at example.com/admin/reports/updates the translation update page was giving the expected results.

jurgenhaas’s picture

Confirmed, that works here as well. Is that something that could and should be improved in l10n_update?

sutharsan’s picture

Title: Handling version mismatches for modules » Fetch available module versions before Update module does.
Category: feature » bug

It needs investigation. If you like to get into it, you can start here:
l10n_update.project.inc, line 50

  if (module_exists('update')) {
    $projects_info = update_get_available(TRUE);
  }

Changed to bug report and modified issue title.

jurgenhaas’s picture

I digged deep into this and it looks as if Drupal is fetching available releases from d.o in function update_fetch_data() in a way so that the process will only take 5 seconds at most. This is driven by function _update_fetch_data() which reads the variable update_max_fetch_time which defaults to UPDATE_MAX_FETCH_TIME = 5.

Therefore, we only ever get 1 or two projects being updated and cached so that modules being later in the alphabet will be updated not at the first time this update function is called and therefore we do not have release data available available until some time later.

How can we overcome that problem?

I can think of three possible approaches:

1) We could call update_fetch_data_batch() to collect all outstanding project releases.

2) We could temporarily variable_set('update_max_fetch_time', $value) to a fairly high value to get a better chance that all release data will be fetched early enough.

3) In l10n_update_build_projects() we could call _update_process_fetch_task() for individual projects in all cases where we can't find data in either $projects or $projects_info

I guess that the first two are not really valueable as they could easily run out of the php time limit which is exactly why those limits have been introduced. Therefore option 3 might be the best approach for now.

What do you think?

sutharsan’s picture

I agree that option 3 is the best solution. Preferably only for those cases where we have a dev release on your hands.

jurgenhaas’s picture

Status: Active » Needs review
StatusFileSize
new1.52 KB

Attached a first patch for review which should resolve this issue.

sutharsan’s picture

Status: Needs review » Needs work
+++ sites/all/modules/l10n_update/l10n_update.project.inc	(revision )
@@ -47,12 +47,19 @@
+    if (!isset($projects_info[$name])) {
+      _update_process_fetch_task($data);
+      $available = _update_get_cached_available_releases();
+      if (!empty($available[$name])) {
+        $projects_info[$name] = $available[$name];
+      }
+    }

Code looks good, but it needs some explanation why this special action is taken.

sutharsan’s picture

@jurgenhaas, can you follow up this issue?

jurgenhaas’s picture

Status: Needs work » Needs review
StatusFileSize
new1.71 KB

Sure thing, please find suggested comment in the attached reroll.

sutharsan’s picture

Version: 7.x-1.0-beta3 » 7.x-1.x-dev
Status: Needs review » Fixed

Patch committed, thanks.
I've trimmed the comment lines to 80 chars as per coding style guide.

JvE’s picture

Status: Fixed » Needs work

This breaks when enabling a module while the update module is disabled.

Fatal error: Call to undefined function _update_process_fetch_task() in l10n_update.project.inc on line 59 
module_enable( )../install.core.inc:1571
module_invoke_all( )../module.inc:499
call_user_func_array ( )../module.inc:899
l10n_update_modules_enabled( )../module.inc:899
l10n_update_project_refresh( )../l10n_update.module:138
l10n_update_build_projects( )../l10n_update.project.inc:150
l10n_update_get_projects( )../l10n_update.project.inc:37
l10n_update_build_projects( )../l10n_update.module:322

_update_process_fetch_task() and _update_get_cached_available_releases() are now called at a time when the update module which defines it may not be enabled yet.

Perhaps the first line should be extended to if (!isset($projects_info[$name]) && module_exists('update')) {

sutharsan’s picture

JvE, yes we should do that.

sutharsan’s picture

Status: Needs work » Needs review
sutharsan’s picture

The right patch...

JvE’s picture

Status: Needs review » Reviewed & tested by the community

Patch solves the problem.

sutharsan’s picture

Status: Reviewed & tested by the community » Fixed

#20 committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.