Created
October 31, 2018 05:55
-
-
Save michaellopez/0b3952d21cec90549e31cce469e60888 to your computer and use it in GitHub Desktop.
Drupal field_collection 7.x-1.0-beta11 version of https://www.drupal.org/files/issues/2018-09-28/field_collection-2936874-php72-11.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/field_collection.entity.inc b/field_collection.entity.inc | |
index 2e8a11b..ed8dfb7 100644 | |
--- a/field_collection.entity.inc | |
+++ b/field_collection.entity.inc | |
@@ -291,24 +291,29 @@ class FieldCollectionItemEntity extends Entity { | |
protected function fetchHostDetails() { | |
if (!isset($this->hostEntityId)) { | |
if ($this->item_id) { | |
+ $in_use = $this->isInUse(); | |
+ | |
// For saved field collections, query the field data to determine the | |
// right host entity. | |
$query = new EntityFieldQuery(); | |
$query->fieldCondition($this->fieldInfo(), 'revision_id', $this->revision_id); | |
- if (!$this->isInUse()) { | |
+ if (!$in_use) { | |
$query->age(FIELD_LOAD_REVISION); | |
} | |
$result = $query->execute(); | |
- list($this->hostEntityType, $data) = each($result); | |
- | |
- if ($this->isInUse()) { | |
- $this->hostEntityId = $data ? key($data) : FALSE; | |
- $this->hostEntityRevisionId = FALSE; | |
- } | |
- // If we are querying for revisions, we get the revision ID. | |
- else { | |
+ if ($result) { | |
+ $this->hostEntityType = key($result); | |
+ $data = current($result); | |
+ end($data); | |
+ | |
+ // The entity ID or revision ID if we are querying for revisions. | |
+ $id = key($data); | |
+ $this->hostEntityId = $in_use ? $id : FALSE; | |
+ $this->hostEntityRevisionId = $in_use ? FALSE : $id; | |
+ } | |
+ else { | |
+ // No host entity available yet. | |
$this->hostEntityId = FALSE; | |
- $this->hostEntityRevisionId = $data ? key($data) : FALSE; | |
} | |
} | |
else { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment