summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.18/sites/all/modules/i18n/i18n_sync/i18n_sync.node.inc
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.18/sites/all/modules/i18n/i18n_sync/i18n_sync.node.inc')
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/i18n/i18n_sync/i18n_sync.node.inc11
1 files changed, 10 insertions, 1 deletions
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/i18n/i18n_sync/i18n_sync.node.inc b/kolab.org/www/drupal-7.18/sites/all/modules/i18n/i18n_sync/i18n_sync.node.inc
index 0480eb7..b18c6f0 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/i18n/i18n_sync/i18n_sync.node.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/i18n/i18n_sync/i18n_sync.node.inc
@@ -27,6 +27,7 @@
* Node operation (insert|update).
*/
function i18n_sync_node_translation($node, $translations, $field_names, $op) {
+ $total = count($translations);
$count = 0;
// Disable language selection and synchronization temporarily, enable it again later
$i18n_select = i18n_select(FALSE);
@@ -34,10 +35,11 @@ function i18n_sync_node_translation($node, $translations, $field_names, $op) {
foreach ($translations as $translation) {
// If translation is the same node, we cannot synchronize with itself
if ($node->nid == $translation->nid) {
+ $total--;
continue;
}
// Load full node, we need all data here.
- $translation = node_load($translation->nid, NULL, TRUE);
+ $translation = node_load($translation->nid);
$i18n_options = i18n_sync_node_options($node->type);
// Invoke callback for each field, the default is just copy over
foreach ($field_names as $field) {
@@ -53,6 +55,13 @@ function i18n_sync_node_translation($node, $translations, $field_names, $op) {
module_invoke_all('i18n_sync_translation', 'node', $translation, $translation->language, $node, $node->language, $field_names);
node_save($translation);
$count++;
+ // Flush each entity from the load cache after processing, to
+ // avoid exceeding PHP memory limits. It should be safe to keep
+ // at least one, however; so we retain the final translation in
+ // the cache after saving it.
+ if ($count < $total) {
+ entity_get_controller('node')->resetCache(array($translation->nid));
+ }
}
i18n_sync(TRUE);
i18n_select($i18n_select);