Skip to content

Instantly share code, notes, and snippets.

@sheise
Created March 10, 2017 16:01
Show Gist options
  • Save sheise/091f6cf9b2deb7b21c8c7c7eca81a7b4 to your computer and use it in GitHub Desktop.
Save sheise/091f6cf9b2deb7b21c8c7c7eca81a7b4 to your computer and use it in GitHub Desktop.
ACF-323: workaround for admin errors on new field collection creation
diff --git a/src/Entity/FieldCollectionItem.php b/src/Entity/FieldCollectionItem.php
index b3f7279..33f64ca 100644
--- a/src/Entity/FieldCollectionItem.php
+++ b/src/Entity/FieldCollectionItem.php
@@ -329,6 +329,13 @@ public function getHostRevisionId() {
$query->range(0, 1);
$result = $query->execute()->fetch();
+ // This is a workaround because when admins create applications
+ // on new hosts, code will get here and find no host causing errors.
+ // TODO: this should be fixed in a better way.
+ if (empty($result)) {
+ return;
+ }
+
$this->host_revision_id = $result->revision_id;
if ($this->host_revision_id) {
$this->host_id = $result->entity_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment