catoegroup / clients-oriented-ftp

Automatically exported from code.google.com/p/clients-oriented-ftp
0 stars 0 forks source link

Deleting an unassigned file from "Manage Files" deletes a different file #497

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Upload a file "A" and assign it to a client
2. Upload another file "B" but do not assign it
3. Go to Manage Files
4. Check the box next to to "B"
5. Select action Delete

What is the expected output? What do you see instead?
Expect "B" to be deleted but "A" is deleted instead.

What version of the product are you using? On what operating system?
r561

Please provide any additional information below.
It looks like the issue is in the checkbox value source in manage-files.php. On 
line 535 it uses $file_id which is set within a loop on line 525. The problem 
is that the file does not have any client assignments, so tbl_files_relations 
has no matches and $query_this_file returns an empty $sql_this_file. The loop 
is skipped and the $file_id from the previous iteration is printed again.

Initializing the variable with $file_id = 0 before the loop mitigates the 
symptom but prevents deletion of unassigned files. It's not clear why the 
Delete action is using tbl_files_relations.id but there doesn't seem to be an 
obvious workaround without rewriting to use tbl_files.id instead.

Original issue reported on code.google.com by jmh...@gmail.com on 29 Aug 2014 at 4:05

GoogleCodeExporter commented 8 years ago
This seems like a big problem.  File counter goes down, so something is being 
deleted?  However the intended file to be deleted remains.

Original comment by dtra...@gmail.com on 3 Sep 2014 at 12:39

GoogleCodeExporter commented 8 years ago
I've been working around this by just deleting directly from tbl_files in the 
MySQL Database. It's annoying, but seems to get rid of the files.

Original comment by zsmith.r...@gmail.com on 10 Sep 2014 at 5:03

GoogleCodeExporter commented 8 years ago
To add to what I was saying before. Deleting from the database removes them 
from the system, but I usually follow up with deleting them off the server 
through the FTP. 

I used the site to delete some files once, but like you said it deleted the 
wrong file!!! I've been afraid since then to use the delete function.

Original comment by zsmith.r...@gmail.com on 16 Sep 2014 at 12:19

GoogleCodeExporter commented 8 years ago
I found a workaround for this problem.

Edit these two files:  upload-process-form.php & edit-file.php

Find this line: <label><?php _e('Assign this file to', 'cftp_admin');?>:</label>

Add this line under it: <input type="hidden" name="file[<?php echo $i; 
?>][assignments][]" value="c1" />

It adds a default hidden association to the system admin user (user #1) for 
every file now, resulting in an entry in the file_relations table and 
preventing the wrong file from being deleted. The file association will show in 
the log file as well, though I'm working on an edit for that as well to hide it.

Original comment by crashf...@gmail.com on 17 Oct 2014 at 5:28