File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -80,17 +80,23 @@ public function archive_files( $entry, $form ) {
8080 continue ;
8181 }
8282 $ nested_form = GFAPI ::get_form ( $ nested_entry ['form_id ' ] );
83- $ nested_archive_files = array_merge ( $ nested_archive_files , $ this ->get_entry_files ( $ nested_entry , $ nested_form ) );
83+ // Add each nested entry files list as a separate array to avoid overriding previously saved files with the same associative array key (the field id).
84+ $ nested_archive_files = array_merge ( $ nested_archive_files , array ( $ this ->get_entry_files ( $ nested_entry , $ nested_form ) ) );
8485 }
8586 }
8687
87- $ archive_files = $ this ->get_entry_files ( $ entry , $ form );
88+ // For conformity with the $nested_archive_files, the current (parent) entry files are also loaded onto an array.
89+ $ archive_files = array ( $ this ->get_entry_files ( $ entry , $ form ) );
8890 $ archive_files = array_merge ( $ archive_files , $ nested_archive_files );
8991 if ( empty ( $ archive_files ) ) {
9092 return ;
9193 }
9294
93- $ archive_file_paths = wp_list_pluck ( $ archive_files , 'path ' );
95+ $ archive_file_paths = array ();
96+ foreach ( $ archive_files as $ archive_file ) {
97+ $ archive_file_path = array_values ( wp_list_pluck ( $ archive_file , 'path ' ) );
98+ $ archive_file_paths = array_merge ( $ archive_file_paths , $ archive_file_path );
99+ }
94100
95101 $ zip = $ this ->create_zip ( $ archive_file_paths , $ this ->get_zip_paths ( $ entry , 'path ' ) );
96102 if ( $ zip ) {
You can’t perform that action at this time.
0 commit comments