summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordaspeter2013-01-10 19:02:16 (GMT)
committer Valery L. Lourie2013-01-10 19:02:16 (GMT)
commit4a6466ae473cdef6944692995975ea727c6638c4 (patch)
tree8ff51ce05ab69d91ee8b440370b9c8ebb69ed602
parent10adcbf662b6d0cb23422dba058c9ef4c28adbf8 (diff)
Issue #1884110 by das-peter: Fixed field translation
-rw-r--r--metatags_quick.admin.inc4
-rw-r--r--metatags_quick.install51
-rw-r--r--metatags_quick.module2
3 files changed, 54 insertions, 3 deletions
diff --git a/metatags_quick.admin.inc b/metatags_quick.admin.inc
index 4b2f303..6ae7322 100644
--- a/metatags_quick.admin.inc
+++ b/metatags_quick.admin.inc
@@ -241,7 +241,7 @@ function metatags_quick_admin_path($form, &$form_state) {
}
$entities = $controller->load(array($entity_id));
$form_state['entity'] = $entities[$entity_id];
- field_attach_form('metatags_path_based', $entities[$entity_id], $form, $form_state);
+ field_attach_form('metatags_path_based', $entities[$entity_id], $form, $form_state, LANGUAGE_NONE);
// Do we have any fields attached?
$childen = element_children($form);
if (!$childen) {
@@ -535,7 +535,7 @@ function metatags_quick_admin_path_based_edit($form, &$form_state) {
}
$form_state['entity'] = $entity;
- field_attach_form('metatags_path_based', $entity, $form, $form_state);
+ field_attach_form('metatags_path_based', $entity, $form, $form_state, LANGUAGE_NONE);
//
$form['entity_id'] = array(
'#type' => 'hidden',
diff --git a/metatags_quick.install b/metatags_quick.install
index e3617df..d472b69 100644
--- a/metatags_quick.install
+++ b/metatags_quick.install
@@ -125,3 +125,54 @@ function metatags_quick_update_7004() {
db_add_unique_key('metatags_quick_path_based', 'lang_path', array('lang', 'path'));
}
}
+
+/**
+ * Ensure the field language of path based fields is set to LANGUAGE_NONE.
+ */
+function metatags_quick_update_7005(&$sandbox) {
+ // Use a sandbox to be able to process huge amounts of data.
+ if (!isset($sandbox['progress'])) {
+ $sandbox['progress'] = 0;
+ $sandbox['current_id'] = 0;
+ // Count items.
+ $sandbox['max'] = db_query("SELECT COUNT(DISTINCT id) FROM {metatags_quick_path_based}")->fetchField();
+ }
+
+ // Process twenty entities at a time.
+ $limit = 20;
+
+ // Fetch the entities to process in this run.
+ $query = new EntityFieldQuery();
+ $query->entityCondition('entity_type', 'metatags_path_based')
+ ->propertyOrderBy('id')
+ ->propertyCondition('id', $sandbox['current_id'], '>')
+ ->range(0, $limit);
+
+ $result = $query->execute();
+
+ if (isset($result['metatags_path_based'])) {
+ $item_ids = array_keys($result['metatags_path_based']);
+ $items = entity_load('metatags_path_based', $item_ids);
+ foreach ($items as $item) {
+ // Iterate over all fields and ensure there's used only LANGUAGE_NONE as
+ // language.
+ $field_infos = field_info_instances('metatags_path_based', 'metatags_path_based');
+ foreach ($field_infos as $field_name => $field_info) {
+ foreach ($item->{$field_name} as $language => $values) {
+ // If the language is different from LANGUAGE_NONE move the values to
+ // LANGUAGE_NONE and remove the "invalid" language.
+ if ($language != LANGUAGE_NONE) {
+ $item->{$field_name}[LANGUAGE_NONE] = $values;
+ unset($item->{$field_name}[$language]);
+ }
+ }
+ }
+ entity_save('metatags_path_based', $item);
+
+ $sandbox['progress']++;
+ $sandbox['current_mlid'] = $item->id;
+ }
+ }
+
+ $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
+}
diff --git a/metatags_quick.module b/metatags_quick.module
index 54d5621..1f0c93f 100644
--- a/metatags_quick.module
+++ b/metatags_quick.module
@@ -215,7 +215,7 @@ function metatags_quick_page_build(&$page) {
$controller = new DrupalDefaultEntityController('metatags_path_based');
$path_entities = $controller->load(array($path_based_id));
foreach ($path_entities as $entity) {
- field_attach_view('metatags_path_based', $entity, 'default');
+ field_attach_view('metatags_path_based', $entity, 'default', LANGUAGE_NONE);
}
}
}