Problem/Motivation
Unfortunately, I'm not sure how to reproduce this; I expect the specific circumstances have something to do with my particular setup, although maybe somebody who is better versed in the code might know what could trigger this condition. One important bit of information is that I just moved the location of the translations directory, so that probably has something to do with it.
Unfortunately I have not been able to get to the root of this problem, but when I try to check for translation updates (manually), the batch process fails with an ajax error, resulting from this notice: "Trying to get property of non-object in locale_translation_source_check_file()". This is on line 173 of locale.translation.inc. The function looks like this:
function locale_translation_source_check_file($source) {
if (isset($source->files[LOCALE_TRANSLATION_LOCAL])) {
$source_file = $source->files[LOCALE_TRANSLATION_LOCAL];
$directory = $source_file->directory;
$filename = '/' . preg_quote($source_file->filename) . '$/';
if ($files = file_scan_directory($directory, $filename, ['key' => 'name', 'recurse' => FALSE])) {
$file = current($files);
$source_file->uri = $file->uri;
$source_file->timestamp = filemtime($file->uri);
return $source_file;
}
}
return FALSE;
}
The source of the problem is the first check, because when things fall over, the key checked for ($source->files['local']) is set to the value FALSE. Line 173 is the one saying $directory = $source_file->directory;
; $source_file is FALSE, by then.
Proposed resolution
Change the check to if (!empty($source->files[LOCALE_TRANSLATION_LOCAL])) {
Remaining tasks
confirm the problem. try to update translations after moving the translation directory.
- Create patch
- Add tests?
- Review
- Commit
User interface changes
None.
API changes
None.
Data model changes
None.