Projet

Général

Profil

Révision 950416da

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

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/field_collection/field_collection.entity.inc
192 192
      list($this->hostEntityId, $this->hostEntityRevisionId) = entity_extract_ids($this->hostEntityType, $this->hostEntity);
193 193
      // If the host entity is not saved yet, set the id to FALSE. So
194 194
      // fetchHostDetails() does not try to load the host entity details.
195
      // Checking value of $this->hostEntityId.
195 196
      if (!isset($this->hostEntityId)) {
196 197
        $this->hostEntityId = FALSE;
197 198
      }
......
231 232
    }
232 233
    list($recieved_id) = entity_extract_ids($this->hostEntityType, $entity);
233 234

  
234
    if ($this->isInUse()) {
235
    if ($this->isInUse() && !empty($this->hostEntityId)) {
235 236
      $current_id = $this->hostEntityId;
236 237
    }
237 238
    else {
......
300 301
  }
301 302

  
302 303
  protected function fetchHostDetails() {
303
    if (!isset($this->hostEntityId)) {
304
    if (!isset($this->hostEntityId) || (!$this->hostEntityId && $this->hostEntityRevisionId)) {
304 305
      if ($this->item_id) {
305 306
        // For saved field collections, query the field data to determine the
306 307
        // right host entity.
......
310 311
          $query->age(FIELD_LOAD_REVISION);
311 312
        }
312 313
        $result = $query->execute();
313
        list($this->hostEntityType, $data) = each($result);
314

  
315
        if ($this->isInUse()) {
316
          $this->hostEntityId = $data ? key($data) : FALSE;
317
          $this->hostEntityRevisionId = FALSE;
314
        if ($result) {
315
          $this->hostEntityType = key($result);
316
          $data = current($result);
317

  
318
          if ($this->isInUse()) {
319
            $data_array_keys = array_keys($data);
320
            $this->hostEntityId = $data ? end($data_array_keys) : FALSE;
321
            $this->hostEntityRevisionId = FALSE;
322
          }
323
          // If we are querying for revisions, we get the revision ID.
324
          else {
325
            $data_array_keys = array_keys($data);
326
            $this->hostEntityId = FALSE;
327
            $this->hostEntityRevisionId = $data ? end($data_array_keys) : FALSE;
328
          }
318 329
        }
319
        // If we are querying for revisions, we get the revision ID.
320 330
        else {
331
          // No host entity available yet.
321 332
          $this->hostEntityId = FALSE;
322
          $this->hostEntityRevisionId = $data ? key($data) : FALSE;
323 333
        }
324 334
      }
325 335
      else {
......
465 475
  /**
466 476
   * Deletes the field collection item and the reference in the host entity.
467 477
   */
468
  public function delete() {
478
  public function delete($skip_host_save = FALSE) {
469 479
    parent::delete();
470
    $this->deleteHostEntityReference();
480
    if (!$skip_host_save) {
481
      $this->deleteHostEntityReference();
482
    }
471 483
  }
472 484

  
473 485
  /**
......
570 582
      }
571 583
      if (!$row && !isset($this->hostEntity()->{$this->field_name}[$this->langcode()][$this->delta()])) {
572 584
        // Delete if there is no existing revision or translation to be saved.
573
        $this->delete();
585
        $this->delete($skip_host_update);
574 586
      }
575 587
    }
576 588
  }

Formats disponibles : Unified diff