Ah! Thanks. We have not updated yet.
In the meantime this is what I did
I made a slight alteration in the following file
…\wp-content\plugins\download-manager\admin\tpls\metaboxes\attach-file.php
The problem is that there is a loop which assigns milliseconds to IDs based on the getTime() function.
This can lead to problems with assignment of duplicate IDs
The change I made was this.
Find this bit of code. Around Line 325
function hide_asset_picker_frame() {
jQuery(‘#wpdm-asset-picker’).remove();
}
function attach_server_files(files) {
jQuery.each(files, function (index, file) {
var d = new Date();
var ID = d.getTime();
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}
And replace with this.
function hide_asset_picker_frame() {
jQuery(‘#wpdm-asset-picker’).remove();
}
var d = new Date().getTime(); // Moved variable before loop
function attach_server_files(files) {
jQuery.each(files, function (index, file) {
//var d = new Date(); commented this out
var ID = d++; // changed to increment rather than assign ID based on systems clock in milliseconds
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}
OK, I managed to get a workaround for this problem.
This is what I did
I made a slight alteration in the following file
…\wp-content\plugins\download-manager\admin\tpls\metaboxes\attach-file.php
The problem is that there is a loop which assigns milliseconds to IDs based on the getTime() function.
This can lead to problems with assignment of duplicate IDs
The change I made was this.
Find this bit of code. Around Line 325
function hide_asset_picker_frame() {
jQuery(‘#wpdm-asset-picker’).remove();
}
function attach_server_files(files) {
jQuery.each(files, function (index, file) {
var d = new Date();
var ID = d.getTime();
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}
And replace with this.
function hide_asset_picker_frame() {
jQuery(‘#wpdm-asset-picker’).remove();
}
var d = new Date().getTime(); // Moved variable before loop
function attach_server_files(files) {
jQuery.each(files, function (index, file) {
//var d = new Date(); commented this out
var ID = d++; // changed to increment rather than assign ID based on systems clock in milliseconds
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}
OK, I managed to get a workaround for this problem.
This is what I did
I made a slight alteration in the following file
…\wp-content\plugins\download-manager\admin\tpls\metaboxes\attach-file.php
The problem is that there is a loop which assigns milliseconds to IDs based on the getTime() function.
This can lead to problems with assignment of duplicate IDs
The change I made was this.
Find this bit of code. Around Line 325
function hide_asset_picker_frame() {
jQuery(‘#wpdm-asset-picker’).remove();
}
function attach_server_files(files) {
jQuery.each(files, function (index, file) {
var d = new Date();
var ID = d.getTime();
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}
And replace with this.
function hide_asset_picker_frame() {
jQuery(‘#wpdm-asset-picker’).remove();
}
var d = new Date().getTime(); // Moved variable before loop
function attach_server_files(files) {
jQuery.each(files, function (index, file) {
//var d = new Date(); commented this out
var ID = d++; // changed to increment rather than assign ID based on systems clock in milliseconds
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}
I’m getting closer to understanding why this is assigning duplicate IDs.
Unfortunately, the unique IDs are being created based on milliseconds using the jQeury.getTime function.
Now this is in the attach-file.php file.
I need to slow this down or have a better way to assign unique IDs
function attach_server_files(files) {
jQuery.each(files, function (index, file) {
var d = new Date();
var ID = d.getTime();
var html = jQuery(‘#wpdm-file-entry’).html();
var ext = file.name.split(‘.’);
ext = ext[ext.length – 1];
if (ext.indexOf(‘://’)) ext = ‘url’;
else if (ext.length == 1 || ext == filename || ext.length > 4 || ext == ”) ext = ‘_blank’;
var icon = “<?php echo WPDM_BASE_URL; ?>file-type-icons/” + ext.toLowerCase() + “.png”;
var title = file.name;
title = title.split(‘/’);
title = title[title.length – 1];
title = title.replace(/\.([\w]+)/, ”);
title = title.replace(/[_|\-]/g, ‘ ‘);
html = html.replace(/##filetitle##/g, file.name);
html = html.replace(/##filepath##/g, file.path);
html = html.replace(/##fileindex##/g, ID);
html = html.replace(/##preview##/g, icon);
jQuery(‘#currentfiles’).prepend(html);
});
}
</script>
</div>
<?php
Hi,
We have come across a bug when adding multiple files from Select from Server when adding files into a package.
We have noticed that, often, there are duplicate IDs being created. After updating, duplicates are omitted from being added to the package and the user has to navigate the cumbersome process of going through Select from Server again.
I believe this is an error in coding which should be wrapped up in a transaction to check that unique IDs are being created beforehand.
I created a 30 second video showing the problem. Link below
Can you please investigate this please?
Thanks
If i disable scripts then the page doesnt work at all for the feature that I have setup on the page
This error prevents another wordpress plugin to work so its very important – its not feasible to just use a browser work around
I told you that the following error occurs (see below) becuase you have not included the js.map file into the project – the other bootstrap js files all have a map file
Could not load content for wp-content/plugins/download-manager/assets/bootstrap/js/popper.min.js.map
Can you fix this in future releases
i cannot do this as we are testing the plugin behind a firewall and we dont allow access