We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 6b4c3310 authored by mattl's avatar mattl

Attachment and file handling since we could get NULL instead of File

parent 2759c3f0
......@@ -1266,14 +1266,12 @@ class Notice extends Managed_DataObject
$ids[] = $f2p->file_id;
$files = File::multiGet('id', $ids);
$this->_attachments[$this->id] = $files->fetchAll();
return $this->_attachments[$this->id];
return $this->_setAttachments(File::multiGet('id', $ids)->fetchAll());
function _setAttachments($attachments)
public function _setAttachments(array $attachments)
$this->_attachments[$this->id] = $attachments;
return $this->_attachments[$this->id] = $attachments;
static function publicStream($offset=0, $limit=20, $since_id=null, $max_id=null)
......@@ -3024,6 +3022,19 @@ class Notice extends Managed_DataObject
$files = array();
$f2ps = $f2pMap[$notice->id];
foreach ($f2ps as $f2p) {
if (!isset($fileMap[$f2p->file_id])) {
// We have probably deleted value from fileMap since
// it as a NULL entry (see the following elseif).
} elseif (is_null($fileMap[$f2p->file_id])) {
// If the file id lookup returned a NULL value, it doesn't
// exist in our file table! So this is a remnant file_to_post
// entry that is no longer valid and should be removed.
common_debug('ATTACHMENT deleting f2p for post_id='.$f2p->post_id.' file_id='.$f2p->file_id);
$files[] = $fileMap[$f2p->file_id];
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment