summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2022-04-10 14:37:45 +0200
committerFlorian Pritz <bluewind@xinu.at>2022-04-10 14:44:35 +0200
commit07bdcad02a01a8451b13ccda18ac5960e008f9d9 (patch)
treedd23c86b2ef18bd335ae80af37cf1957d2dca0fd
parent7dd87f5bccda650f5d69e521f1cc9d33e2994b75 (diff)
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 <bluewind@xinu.at>
-rw-r--r--NEWS1
-rw-r--r--application/controllers/file/Multipaste.php5
2 files changed, 6 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index e3d35900e..3b88db5c2 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ This file lists major, incompatible or otherwise important changes, you should l
NEXT
- BREAKING CHANGE: Minimum requried PHP version is now >= 7
- More PHP 8.1 compatibility fixes
+ - Fix exception in multipaste queue when queued item has been deleted
3.6.2 2022-01-09
- Use python3 instead of python for Ubuntu 20.04 and Debian 11 compatibility.
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);