Fix weird "Default object created from empty vlaue" error

Looks like $file can be NULL sometimes, though that should be illegal. Probably an unfixed post.php bug...
This commit is contained in:
8chan 2014-12-20 14:00:48 -08:00
parent 01cca90597
commit bb81e9e0c3

View File

@ -357,9 +357,14 @@ class Post {
if (isset($this->files) && $this->files) { if (isset($this->files) && $this->files) {
$this->files = json_decode($this->files); $this->files = json_decode($this->files);
// Compatibility for posts before individual file hashing // Compatibility for posts before individual file hashing
foreach ($this->files as &$file) foreach ($this->files as $i => &$file) {
if (empty($file)) {
unset($this->files[$i]);
continue;
}
if (!isset($file->hash)) if (!isset($file->hash))
$file->hash = $this->filehash; $file->hash = $this->filehash;
}
} }
$this->subject = utf8tohtml($this->subject); $this->subject = utf8tohtml($this->subject);