For some days I was getting the l10n update message, "Failed to fetch information about available updates from the server." The code in l10n_update_admin_import_form_submit() that generates it is:
// Get available translation updates and update file history.
if ($available = l10n_update_available_releases(TRUE)) {
l10n_update_flag_history($available);
drupal_set_message(t('Fetched information about available updates from the server'));
}
else {
drupal_set_message(t('Failed to fetch information about available updates from the server.'), 'error');
}The $available variable in this code wasn't being set here because, in the following code, result->code wasn't set to 200:
function l10n_update_http_check($url, $headers = array()) {
$result = l10n_update_http_request($url, array('headers' => $headers, 'method' => 'HEAD'));
if ($result && $result->code == '200') {
$result->updated = isset($result->headers['last-modified']) ? strtotime($result->headers['last-modified']) : 0;
}
return $result;Instead, $result->code was set to 403, which is 'forbidden'. More research showed that I hadn't set the .htaccess file to allow .po files.
There's an issue posted in D8 to remove .po protection. This appears to me to be the best solution for this particular problem in D7. (http://drupal.org/node/1763068). Another possibility is the patch lucascaro posted at http://drupal.org/node/1011532?mode=2&sort=2
However, this sort of thing could happen with with other problems, not just the 403 error I hit. Down in l10n_update_http_check(), the code is stored off int $result->code, but by the time Drupal works back out to l10n_update_admin_import_form_submit(), all it knows is no releases are available. As the code currently stands, it's not easy to figure out why not.
Nor is it easy to know what to recommend to improve the code. Ideally it would be nice to have more than a generic message than the program failed to fetch update information from the server.
Comments
Comment #1
inkling commentedA similar issue was logged at http://drupal.org/node/1791100#comment-6740826.
Comment #2
sutharsan commentedAre you importing/trying to import po file over http from the domain your Drupal site runs? Please explain your configuration. l10n_update module has a concept of 'remote' and 'local' files. Why do you import po files as remote files?
Comment #3
inkling commentedMaybe I'm misunderstanding the concept of local and remote files.
Our configuration is to retrieve translation files from localize.drupal.org (l.d.o.) and store them on our own localization server, which I will call l.my.o for now. Then client sites can download them from l.my.o. to their own sites:
l.d.o. ==> l.my.o. ==> client siteThen they can share translations at l.my.o. and ultimately with l.d.o. if they so choose:
l.d.o. <== l.my.o. <== client siteThe client site may well be on the same server as l.my.o., but I'm thinking the possibility exists that it could also be somewhere else.
As far as I know, the files located at l.my.o. would be remote files for the client site.
Comment #4
sutharsan commentedIf the above '403' is reported by the 'client site', than the l.my.o is just configured badly. You should or modify the .htaccess or server the po files from a different directory. The current code includes a watchdog message. That's all that l10n_update can provide.