Welcome Guest, Not a member yet? Register   Sign In
[solved] Finding a bug when you don't find the right action to make a situation when bug appears
#2

[eluser]SPeed_FANat1c[/eluser]
Code:
function delete_picture_edit_ajax()
{
        
   $this->db->where('filename',$this->input->post('filename'))->delete('naujienu_nuotraukos');        
   if($this->membership->is_logged_in())
   {
        unlink('./uploads/naujienos/'.$this->input->post('filename'));
   }
   else echo 'not_admin';
}

in this function it might be that the record from database is removed when the admin is not logged in and the filename from server is not removed. But its hard to believe that because of this problem half of the filenames are removed. Admin should not even want to remove that much pictures.. But corrected this code - made it check if the admin is logged in before delete from db.

EDIT:

from another forum I got such answer:
Quote:First thing that you might want to do is to log all the pertinent info when you delete anything. The second thing that you might want to do (at least for a while) is to do a soft-delete instead. Just mark the record as deleted or save a copy under a special "deleted" key or move it to another "deleted record" table.

With both of these in place you will be able to investigate what is going on and you won't permanently lose any data.

So I will try to log and to soft delete and maybe will catch somehow when those unnecesary deletes happen.


Messages In This Thread
[solved] Finding a bug when you don't find the right action to make a situation when bug appears - by El Forum - 04-06-2011, 12:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB