From 6f8786f3ad5bd8c9030b93230bed6bce3ff6b37e Mon Sep 17 00:00:00 2001 From: Jakob Buis Date: Fri, 14 Apr 2017 13:14:26 +0200 Subject: [PATCH 1/3] added null-check to prevent crashing on incomplete fields --- src/Field/FlexibleContent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Field/FlexibleContent.php b/src/Field/FlexibleContent.php index 2b13389..2fce43d 100644 --- a/src/Field/FlexibleContent.php +++ b/src/Field/FlexibleContent.php @@ -99,7 +99,7 @@ protected function fetchFields($fieldName, Builder $builder) $post = $this->post->ID != $meta->post_id ? $this->post->find($meta->post_id) : $this->post; $field = FieldFactory::make($meta->meta_key, $post); - if (!array_key_exists($id, $blocks)) { + if ($field === null || !array_key_exists($id, $blocks)) { continue; } From e37a557b32d221a85912b656b278100e7a192818 Mon Sep 17 00:00:00 2001 From: Jakob Buis Date: Fri, 14 Apr 2017 13:19:02 +0200 Subject: [PATCH 2/3] added explicit cast to int to prevent problems in using range() when wordpress sometimes returns a string representation of the integer --- src/Field/Repeater.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Field/Repeater.php b/src/Field/Repeater.php index 0a2a459..6eb7ddb 100644 --- a/src/Field/Repeater.php +++ b/src/Field/Repeater.php @@ -74,7 +74,7 @@ protected function retrieveFieldName($metaKey, $fieldName, $id) */ protected function fetchPostsMeta($fieldName, Post $post) { - $count = $this->fetchValue($fieldName, $post); + $count = (int) $this->fetchValue($fieldName, $post); $builder = $this->postMeta->where('post_id', $post->ID); $builder->where(function ($query) use ($count, $fieldName) { foreach (range(0, $count - 1) as $i) { From f2116dd509a0dcc0001a3954d740c89d80927b95 Mon Sep 17 00:00:00 2001 From: Jakob Buis Date: Wed, 26 Apr 2017 15:12:45 +0200 Subject: [PATCH 3/3] Image must expose its attachment for metadata access through ->attachment->meta-> --- src/Field/Image.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Field/Image.php b/src/Field/Image.php index 5bca7b1..d5f1acd 100644 --- a/src/Field/Image.php +++ b/src/Field/Image.php @@ -85,6 +85,8 @@ public function get() */ protected function fillFields(Post $attachment) { + $this->attachment = $attachment; + $this->mime_type = $attachment->post_mime_type; $this->url = $attachment->guid; $this->description = $attachment->post_excerpt;