Projet

Général

Profil

Révision b4adf10d

Ajouté par Assos Assos il y a plus de 9 ans

Udpate to 7.33

Voir les différences:

drupal7/modules/field/modules/field_sql_storage/field_sql_storage.module
64 64
  }
65 65
}
66 66

  
67
/**
68
 * Generates a table alias for a field data table.
69
 *
70
 * The table alias is unique for each unique combination of field name
71
 * (represented by $tablename), delta_group and language_group.
72
 *
73
 * @param $tablename
74
 *   The name of the data table for this field.
75
 * @param $field_key
76
 *   The numeric key of this field in this query.
77
 * @param $query
78
 *   The EntityFieldQuery that is executed.
79
 *
80
 * @return
81
 *   A string containing the generated table alias.
82
 */
83
function _field_sql_storage_tablealias($tablename, $field_key, EntityFieldQuery $query) {
84
  // No conditions present: use a unique alias.
85
  if (empty($query->fieldConditions[$field_key])) {
86
    return $tablename . $field_key;
87
  }
88

  
89
  // Find the delta and language condition values and append them to the alias.
90
  $condition = $query->fieldConditions[$field_key];
91
  $alias = $tablename;
92
  $has_group_conditions = FALSE;
93

  
94
  foreach (array('delta', 'language') as $column) {
95
    if (isset($condition[$column . '_group'])) {
96
      $alias .= '_' . $column . '_' . $condition[$column . '_group'];
97
      $has_group_conditions = TRUE;
98
    }
99
  }
100

  
101
  // Return the alias when it has delta/language group conditions.
102
  if ($has_group_conditions) {
103
    return $alias;
104
  }
105

  
106
  // Return a unique alias in other cases.
107
  return $tablename . $field_key;
108
}
109

  
67 110
/**
68 111
 * Generate a column name for a field data table.
69 112
 *
......
504 547
    $id_key = 'revision_id';
505 548
  }
506 549
  $table_aliases = array();
550
  $query_tables = NULL;
507 551
  // Add tables for the fields used.
508 552
  foreach ($query->fields as $key => $field) {
509 553
    $tablename = $tablename_function($field);
510
    // Every field needs a new table.
511
    $table_alias = $tablename . $key;
554
    $table_alias = _field_sql_storage_tablealias($tablename, $key, $query);
512 555
    $table_aliases[$key] = $table_alias;
513 556
    if ($key) {
514
      $select_query->join($tablename, $table_alias, "$table_alias.entity_type = $field_base_table.entity_type AND $table_alias.$id_key = $field_base_table.$id_key");
557
      if (!isset($query_tables[$table_alias])) {
558
        $select_query->join($tablename, $table_alias, "$table_alias.entity_type = $field_base_table.entity_type AND $table_alias.$id_key = $field_base_table.$id_key");
559
      }
515 560
    }
516 561
    else {
517 562
      $select_query = db_select($tablename, $table_alias);
563
      // Store a reference to the list of joined tables.
564
      $query_tables =& $select_query->getTables();
518 565
      // Allow queries internal to the Field API to opt out of the access
519 566
      // check, for situations where the query's results should not depend on
520 567
      // the access grants for the current user.

Formats disponibles : Unified diff