Commit b36b17ed authored by webchick's avatar webchick

Issue #1884182 by Gábor Hojtsy, Sutharsan: Fixed Import of large number of...

Issue #1884182 by Gábor Hojtsy, Sutharsan: Fixed Import of large number of translations fails on SQLite.
parent f5d69718
......@@ -102,7 +102,6 @@ function setReport($report = array()) {
'updates' => 0,
'deletes' => 0,
'skips' => 0,
'strings' => array(),
);
$this->_report = $report;
}
......@@ -259,7 +258,6 @@ private function importString(PoItem $item) {
$string->save();
$this->_report['updates']++;
}
$this->_report['strings'][] = $string->getId();
return $string->lid;
}
else {
......@@ -274,7 +272,6 @@ private function importString(PoItem $item) {
))->save();
$this->_report['additions']++;
$this->_report['strings'][] = $string->getId();
return $string->lid;
}
}
......@@ -282,7 +279,6 @@ private function importString(PoItem $item) {
// Empty translation, remove existing if instructed.
$string->delete();
$this->_report['deletes']++;
$this->_report['strings'][] = $string->lid;
return $string->lid;
}
}
......
......@@ -543,7 +543,7 @@ function locale_translate_batch_import_save($context) {
function locale_translate_batch_finished($success, $results) {
if ($success) {
$additions = $updates = $deletes = $skips = 0;
$strings = $langcodes = array();
$langcodes = array();
if (isset($results['failed_files'])) {
if (module_exists('dblog')) {
$message = format_plural(count($results['failed_files']), 'One translation file could not be imported. <a href="@url">See the log</a> for details.', '@count translation files could not be imported. <a href="@url">See the log</a> for details.', array('@url' => url('admin/reports/dblog')));
......@@ -566,10 +566,8 @@ function locale_translate_batch_finished($success, $results) {
if ($report['skips'] > 0) {
$skipped_files[] = $filepath;
}
$strings = array_merge($strings, $report['strings']);
}
// Get list of unique string identifiers and language codes updated.
$strings = array_unique($strings);
// Get list of unique language codes updated.
$langcodes = array_unique(array_values($results['languages']));
}
drupal_set_message(format_plural(count($results['files']),
......@@ -590,10 +588,8 @@ function locale_translate_batch_finished($success, $results) {
watchdog('locale', '@count disallowed HTML string(s) in files: @files.', array('@count' => $skips, '@files' => implode(',', $skipped_files)), WATCHDOG_WARNING);
}
if ($strings) {
// Clear cache and force refresh of JavaScript translations.
_locale_refresh_translations($langcodes, $strings);
}
// Clear cache and force refresh of JavaScript translations.
_locale_refresh_translations($langcodes);
}
}
}
......
......@@ -1028,12 +1028,14 @@ function locale_string_is_safe($string) {
* @param array $langcodes
* Language codes for updated translations.
* @param array $lids
* List of string identifiers that have been updated / created.
* (optional) List of string identifiers that have been updated / created.
* If not provided, all caches for the affected languages are cleared.
*/
function _locale_refresh_translations($langcodes, $lids) {
if ($lids && $langcodes) {
// Update javascript translations if any of the strings has a javascript location.
if ($strings = locale_storage()->getStrings(array('lid' => $lids, 'type' => 'javascript'))) {
function _locale_refresh_translations($langcodes, $lids = array()) {
if (!empty($langcodes)) {
// Update javascript translations if any of the strings has a javascript
// location, or if no string ids were provided, update all languages.
if (empty($lids) || ($strings = locale_storage()->getStrings(array('lid' => $lids, 'type' => 'javascript')))) {
array_map('_locale_invalidate_js', $langcodes);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment