From 07bdcad02a01a8451b13ccda18ac5960e008f9d9 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sun, 10 Apr 2022 14:37:45 +0200 Subject: fix(multipaste): Handle missing items in multipaste queue This fixes an exception if the multipaste queue contains an item that does not exist any more, e.g. because it has been deleted after it was added to the queue. `Exception 1/1 'ErrorException' with message 'Trying to access array offset on value of type bool' in /srv/http/filebin/application/controllers/file/Multipaste.php:103` Signed-off-by: Florian Pritz --- application/controllers/file/Multipaste.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'application/controllers') diff --git a/application/controllers/file/Multipaste.php b/application/controllers/file/Multipaste.php index cc8ab8819..bc042e2f3 100644 --- a/application/controllers/file/Multipaste.php +++ b/application/controllers/file/Multipaste.php @@ -46,6 +46,7 @@ class Multipaste extends MY_Controller { $this->data['ids'] = $ids; $this->data['items'] = array_map(function($id) {return $this->_get_multipaste_item($id);}, $ids); + $this->data['items'] = array_filter($this->data['items'], function($item) {return $item !== false;}); $this->load->view('header', $this->data); $this->load->view('file/multipaste/queue', $this->data); @@ -99,6 +100,10 @@ class Multipaste extends MY_Controller { private function _get_multipaste_item($id) { $filedata = $this->mfile->get_filedata($id); + if ($filedata === false) { + return false; + } + $item = []; $item['id'] = $filedata['id']; $item['tooltip'] = \service\files::tooltip($filedata); -- cgit v1.2.3-24-g4f1b