From cdde589d6abe9ee1b116209ca936a8d84840fd35 Mon Sep 17 00:00:00 2001 From: Fred Brennan Date: Tue, 24 Jan 2023 02:31:19 -0500 Subject: [PATCH] Apply inc/display.php@0a2dfed from vichan/infinity --- inc/display.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/inc/display.php b/inc/display.php index 9da3c58d..de52781f 100644 --- a/inc/display.php +++ b/inc/display.php @@ -348,8 +348,18 @@ class Post { $this->{$key} = $value; } - if (isset($this->files) && $this->files) - $this->files = @json_decode($this->files); + if (isset($this->files) && $this->files) { + $this->files = is_string($this->files) ? json_decode($this->files) : $this->files; + // Compatibility for posts before individual file hashing + foreach ($this->files as $i => &$file) { + if (empty($file)) { + unset($this->files[$i]); + continue; + } + if (!isset($file->hash)) + $file->hash = $this->filehash; + } + } $this->subject = utf8tohtml($this->subject); $this->name = utf8tohtml($this->name); @@ -399,7 +409,7 @@ class Thread { } if (isset($this->files)) - $this->files = @json_decode($this->files); + $this->files = is_string($this->files) ? json_decode($this->files) : $this->files; $this->subject = utf8tohtml($this->subject); $this->name = utf8tohtml($this->name);