I'm in the process of cleaning up roughly 17,000 old file records and I noticed that when I try to manually delete multiple records in the 'Manual' tab with the fid's only the last fid supplied is deleted. I believe the issue was in the fancy_file_delete.batch.inc file lines 20-21. All the $fid's being supplied were failing the is_numeric check, and I believe because it has to do with line endings. So what I did was just wrap the $fid with (int) so it now passes the is_numeric check and file_load is also working. I've attached the patch for review.

Comments

smustgrave created an issue. See original summary.

labboy0276’s picture

Assigned: Unassigned » labboy0276

Thanks for this, just getting caught up post Drupalcon and will look at this and add it in if it looks good.

  • labboy0276 committed 3a28216 on 7.x-1.x authored by smustgrave
    Issue #2719619 by smustgrave, labboy0276: Unable to use manual deletion...
labboy0276’s picture

Status: Active » Closed (fixed)

OK

Thanks for this. When type casting a string, if it fails, it returns 0. So putting a type cast in is_numeric will always pass. So I changed the code up some to reflect this and to remove the line endings as well (str_replace is faster than preg_replace):

// Remove line endings to prevent fail and convert to integer.
// @see https://www.drupal.org/node/2719619 for related issue.
$fid = str_replace(array("\r", "\n"), '', $fid);
$fid = (int) $fid;

// Manual / Orphan Delete.
if ($fid) {

Also, when creating a patch, don't do it from root, your patch failed on my system. Gave you credit and again thanks for this.