Skip to content

Commit

Permalink
Fix: Multiple upload fields on a single table
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanJard committed Aug 4, 2021
1 parent b0a2317 commit 5e1e86c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ private function _fileData ( $limitTable=null, $ids=null, $data=null )
* only
* @private
*/
private function _fileDataFields ( &$files, $fields, $limitTable, $ids=null, $data=null )
private function _fileDataFields ( &$files, $fields, $limitTable, $idsIn=null, $data=null )
{
foreach ($fields as $field) {
$upload = $field->upload();
Expand All @@ -1488,6 +1488,8 @@ private function _fileDataFields ( &$files, $fields, $limitTable, $ids=null, $da

// Make a collection of the ids used in this data set to get a limited data set
// in return (security and performance)
$ids = $idsIn;

if ( $ids === null ) {
$ids = array();
}
Expand All @@ -1496,14 +1498,14 @@ private function _fileDataFields ( &$files, $fields, $limitTable, $ids=null, $da
for ( $i=0, $ien=count($data); $i<$ien ; $i++ ) {
$val = $field->val( 'set', $data[$i] );

if ( $val ) {
if ( $val && ! in_array($val, $ids) ) {
$ids[] = $val;
}
}

if ( count($ids) === 0 ) {
// If no data to fetch, then don't bother
return;
// If no data to fetch for this field, so don't bother
continue;
}
else if ( count($ids) > 1000 ) {
// Don't use `where_in` for really large data sets
Expand Down

0 comments on commit 5e1e86c

Please sign in to comment.