Projet

Général

Profil

Révision d719f12f

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

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/plugins/views_plugin_query_default.inc
143 143
    );
144 144

  
145 145
/**
146
 * -- we no longer want the base field to appear automatigically.
146
 * -- we no longer want the base field to appear automatically.
147 147
    if ($base_field) {
148 148
      $this->fields[$base_field] = array(
149 149
        'table' => $base_table,
......
888 888
  /**
889 889
   * Add a complex WHERE clause to the query.
890 890
   *
891
   * The caller is reponsible for ensuring that all fields are fully qualified
891
   * The caller is responsible for ensuring that all fields are fully qualified
892 892
   * (TABLE.FIELD) and that the table already exists in the query.
893 893
   * Internally the dbtng method "where" is used.
894 894
   *
......
1620 1620
    }
1621 1621
    $entity_type = $table_data['table']['entity type'];
1622 1622
    $info = entity_get_info($entity_type);
1623
    $id_alias = $this->get_field_alias($base_table_alias, $info['entity keys']['id']);
1623
    $is_revision = !empty($table_data['table']['revision']);
1624
    $id_alias = $this->get_field_alias($base_table_alias, $info['entity keys'][$is_revision ? 'revision' : 'id']);
1624 1625

  
1625 1626
    // Assemble the ids of the entities to load.
1626 1627
    $ids = array();
......
1630 1631
      }
1631 1632
    }
1632 1633

  
1633
    $entities = entity_load($entity_type, $ids);
1634
    // Re-key the array by row-index.
1635
    $result = array();
1636
    foreach ($ids as $key => $id) {
1637
      $result[$key] = isset($entities[$id]) ? $entities[$id] : FALSE;
1634
    if (!$is_revision) {
1635
      $entities = entity_load($entity_type, $ids);
1636

  
1637
      // Re-key the array by row-index.
1638
      $result = array();
1639
      foreach ($ids as $key => $id) {
1640
        $result[$key] = isset($entities[$id]) ? $entities[$id] : FALSE;
1641
      }
1638 1642
    }
1643
    else {
1644
      // There's no way in core to load revisions in bulk.
1645
      $result = array();
1646
      foreach ($ids as $key => $id) {
1647
        // Nodes can be dealt with in core.
1648
        if ($entity_type == 'node') {
1649
          $result[$key] = node_load(NULL, $id);
1650
        }
1651
        // Otherwise see if entity is enabled.
1652
        elseif (module_exists('entity')) {
1653
          $result[$key] = entity_revision_load($entity_type, $id);
1654
        }
1655
        else {
1656
          // Otherwise this isn't supported.
1657
          watchdog('views', 'Attempt to load a revision on an unsupported entity type @entity_type.', array('@entity_type' => $entity_type), WATCHDOG_WARNING);
1658
        }
1659
      }
1660
    }
1661

  
1639 1662
    return array($entity_type, $result);
1640 1663
  }
1641 1664
}

Formats disponibles : Unified diff