aboutsummaryrefslogtreecommitdiff
path: root/classes/File_to_post.php
diff options
context:
space:
mode:
authorMikael Nordfeldth <mmn@hethane.se>2015-06-04 17:36:11 +0200
committerMikael Nordfeldth <mmn@hethane.se>2015-06-04 17:36:11 +0200
commitfe6498e7c875f5b386a9c7d2cc1fba5677daae09 (patch)
treea7a52034d2f4b8098398567f148874233bc162a2 /classes/File_to_post.php
parent5358fb3cce663c4903fdc35a07b731d45c3ab279 (diff)
downloadgnu-social-fe6498e7c875f5b386a9c7d2cc1fba5677daae09.tar
gnu-social-fe6498e7c875f5b386a9c7d2cc1fba5677daae09.zip
Send objects instead of integers to File_to_post::processNew
Diffstat (limited to 'classes/File_to_post.php')
-rw-r--r--classes/File_to_post.php23
1 files changed, 11 insertions, 12 deletions
diff --git a/classes/File_to_post.php b/classes/File_to_post.php
index b3c44d4a22..7f2aca3362 100644
--- a/classes/File_to_post.php
+++ b/classes/File_to_post.php
@@ -58,30 +58,29 @@ class File_to_post extends Managed_DataObject
);
}
- function processNew($file_id, $notice_id) {
+ function processNew(File $file, Notice $notice) {
static $seen = array();
+
+ $file_id = $file->getID();
+ $notice_id = $notice->getID();
+ if (!array_key_exists($notice_id, $seen)) {
+ $seen[$notice_id] = array();
+ }
+
if (empty($seen[$notice_id]) || !in_array($file_id, $seen[$notice_id])) {
$f2p = File_to_post::pkeyGet(array('post_id' => $notice_id,
'file_id' => $file_id));
- if (empty($f2p)) {
+ if (!$f2p instanceof File_to_post) {
$f2p = new File_to_post;
$f2p->file_id = $file_id;
$f2p->post_id = $notice_id;
$f2p->insert();
- $f = File::getKV($file_id);
-
- if (!empty($f)) {
- $f->blowCache();
- }
+ $file->blowCache();
}
- if (empty($seen[$notice_id])) {
- $seen[$notice_id] = array($file_id);
- } else {
- $seen[$notice_id][] = $file_id;
- }
+ $seen[$notice_id][] = $file_id;
}
}