From 218050a94641657c9fd189031f99415202513f98 Mon Sep 17 00:00:00 2001 From: Awilum Date: Wed, 26 Feb 2020 20:43:50 +0300 Subject: [PATCH] fix(core): fix issue with system fields data types in the Entries API #383 slug field should be string routable field should be boolean visibility field should be string one of (visible, draft, hidden) created_at field should be int unix timestamp published_at field should be int unix timestamp modified_at field should be int unix timestamp --- flextype/core/Entries.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flextype/core/Entries.php b/flextype/core/Entries.php index d8ab5aea..1c6d25fa 100755 --- a/flextype/core/Entries.php +++ b/flextype/core/Entries.php @@ -184,23 +184,23 @@ class Entries // // Entry Published At - $entry_decoded['published_at'] = (int) strtottime($entry_decoded['published_at']) ?? Filesystem::getTimestamp($entry_file); + $entry_decoded['published_at'] = isset($entry_decoded['published_at']) ? (int) strtotime($entry_decoded['published_at']) : (int) Filesystem::getTimestamp($entry_file); // Entry Created At - $entry_decoded['created_at'] = (int) strtottime($entry_decoded['created_at']) ?? Filesystem::getTimestamp($entry_file); + $entry_decoded['created_at'] = isset($entry_decoded['created_at']) ? (int) strtotime($entry_decoded['created_at']) : (int) Filesystem::getTimestamp($entry_file); // Entry Modified $entry_decoded['modified_at'] = (int) Filesystem::getTimestamp($entry_file); // Entry Slug - $entry_decoded['slug'] = (string) $entry_decoded['slug'] ?? ltrim(rtrim($id, '/'), '/'); + $entry_decoded['slug'] = isset($entry_decoded['slug']) ? (string) $entry_decoded['slug'] : (string) ltrim(rtrim($id, '/'), '/'); // Entry Routable - $entry_decoded['routable'] = (bool) $entry_decoded['routable'] ?? true; + $entry_decoded['routable'] = isset($entry_decoded['routable']) ? (bool) $entry_decoded['routable'] : true; // Entry Visibility - if (isset($entry_decoded['visibility']) && in_array($this->visibility[$entry_decoded['visibility']])) { - $entry_decoded['visibility'] = (string) $entry_decoded['visibility']; + if (isset($entry_decoded['visibility']) && in_array($entry_decoded['visibility'], $this->visibility)) { + $entry_decoded['visibility'] = (string) $this->visibility[$entry_decoded['visibility']]; } else { $entry_decoded['visibility'] = (string) $this->visibility['visible']; }