From a92a3f8b1bf741f5d3f47acc8ed9e9fc23fcfd35 Mon Sep 17 00:00:00 2001 From: JediKev <kevin@enhancesoft.com> Date: Mon, 5 Nov 2018 09:30:48 -0600 Subject: [PATCH] issue: FAQ/Page Attachments This addresses an issue where inserting images on a Page or FAQ and having the setting enabled for "Login required to view attachments." does not display the images at all when the Page/FAQ renders in view. This is due to the Page/FAQ update functions that were not updated to fit the new `id=>name` format for `keepOnlyFileIds()` introduced with `f179cf1`. --- include/class.faq.php | 2 +- include/class.page.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/class.faq.php b/include/class.faq.php index 555fd3aee..38e20b55c 100644 --- a/include/class.faq.php +++ b/include/class.faq.php @@ -405,7 +405,7 @@ class FAQ extends VerySimpleModel { } $images = Draft::getAttachmentIds($vars['answer']); - $images = array_map(function($i) { return $i['id']; }, $images); + $images = array_flip(array_map(function($i) { return $i['id']; }, $images)); $this->getAttachments()->keepOnlyFileIds($images, true); // Handle language-specific attachments diff --git a/include/class.page.php b/include/class.page.php index a430fc2e6..1eb738710 100644 --- a/include/class.page.php +++ b/include/class.page.php @@ -282,7 +282,7 @@ class Page extends VerySimpleModel { // Attach inline attachments from the editor $keepers = Draft::getAttachmentIds($vars['body']); - $keepers = array_map(function($i) { return $i['id']; }, $keepers); + $keepers = array_flip(array_map(function($i) { return $i['id']; }, $keepers)); $this->attachments->keepOnlyFileIds($keepers, true); if ($rv) -- GitLab