Browse Source

[UPDATE] avoid using notes cache when retrieving files to include changes to records done in the same script

experimental
Georgi Hristov 2 years ago
parent
commit
0964a6b8ab
1 changed files with 22 additions and 19 deletions
  1. +22
    -19
      modules/Utils/Attachment/AttachmentCommon_0.php

+ 22
- 19
modules/Utils/Attachment/AttachmentCommon_0.php View File

@@ -142,25 +142,24 @@ class Utils_AttachmentCommon extends ModuleCommon {

public static function get_files($group=null,$group_starts_with=false) {
$ids = self::get_where($group,$group_starts_with);
if(!$ids) return array();
$files = array();
foreach($ids as $id) {
$note = self::get_note($id);
foreach($note['files'] as $fsid) {
$meta = Utils_FileStorageCommon::meta($fsid);
$files[] = array_merge($meta, $note, array(
'id' => $fsid,
'note_id' => $id,
'file_id' => null,
'upload_by' => $meta['created_by'],
'upload_on' => $meta['created_by'],
'original' => $meta['filename'],
'filestorage_id' => $fsid,
'downloads' => Utils_FileStorageCommon::get_downloads_count($fsid),
));
}
}
if(!$ids) return [];
$files = [];
foreach (self::get_notes(['id' => $ids]) as $id => $note) {
foreach($note['files']?? [] as $fsid) {
$meta = Utils_FileStorageCommon::meta($fsid);
$files[] = array_merge($meta, $note, array(
'id' => $fsid,
'note_id' => $id,
'file_id' => null,
'upload_by' => $meta['created_by'],
'upload_on' => $meta['created_by'],
'original' => $meta['filename'],
'filestorage_id' => $fsid,
'downloads' => Utils_FileStorageCommon::get_downloads_count($fsid),
));
}
}
return $files;
}

@@ -610,6 +609,10 @@ class Utils_AttachmentCommon extends ModuleCommon {
}
return $cache[$id];
}
public static function get_notes($crits = array(), $cols = array(), $order = array(), $limit = array(), $admin = false) {
return Utils_RecordBrowserCommon::get_records('utils_attachment', $crits, $cols, $order, $limit, $admin);
}

/**
* Create new watchdog event for record if $group denotes record.


Loading…
Cancel
Save