Hi,

this is a really serious bug, reverting a node with gallery assist enabled to an old revision will delete ALL the files in the gallery_assist path.

Please correct it as quick as possible. Unfortunately i didn't have the time to investigate.

If you need some more info please feel free to ask me. This happen at least in version 1.8 and 1.9-rc2
Anselmo

Comments

fw_crocodile’s picture

The problem is probably related to function gallery_assist_update()

fw_crocodile’s picture

There are at least two problems.

First: you should probably move $ganame = 'gallery_assist'. $node->ref; outside the if (count($node->gallery_items) > 0) or ganame could be undefined in // Delete the old gallery folder.

Second:$node->current_owner apparently didn't exist in this scope

Third: $move_to_path should be $move_to_path = $user_gallery_directory . '/' . $ganame;

I'm investigating the current_owner problem. I will post a patch if I found a solution.

jcmc’s picture

Hello fw_crocodile,

I have to investigate why is called my hook_delete.

You had right, a possible place of the issue is the hook_update.

I have created patches for GA v 1.8 and 1.9-rc2.

Can you test, please?

Regards and many thanks
Juan Carlos

fw_crocodile’s picture

I could not test the 1.8 for the moment.

But the 1.9-rc2 seems to work right.

I think the problem was that current_owner wasn't defined in the revision "page" so the condition if ($node->uid != $node->current_owner) was true (may be a too simple check). And finally the gallery_assist_delete_directory was called with files/gallery_assist argument deleting all the contents (a watchdog() in the delete function could have leaved some trace in the logs).

Two little error remain I think.

// Delete the old gallery folder.
      if (gallery_assist_delete_directory(file_directory_path() .'/gallery_assist/'. $node->current_owner .'/'. $ganame)) {
        drupal_set_message(t('<b>The new owner of this gallery is user: @uname</b>', array('@uname' => $node->name)));
      }

Use $ganame but $ganame is defined only if the precedent if statement is executed. (line 1608)

Sometimes you use variable_get('gallery_assist_directory', file_directory_path() .'/gallery_assist') and sometimes only the hardcoded file_directory_path() .'/gallery_assist/'.

I think you should always use the first one (I may be wrong naturally). See lines: 1626 1627 1645

Thank's for the quick fix.

Anselmo

jcmc’s picture

Hi Anselmo,

About the "two little errors",

Yes, a too simple check, I extend the check allready and here the patch.

The secund is not a bug, I have reasons so I use the two methods.

Thanks and regards
Juan Carlos

PS
I change the status to fixed, I remember you posted in the pas the same issue but I not find it by normaly search.

fw_crocodile’s picture

Hi,

I didn't remember to have found a similar problem in the past, anyway the bug #682562: Creating new galleries causes deleting directories could be related to the same problem.

jcmc’s picture

Status: Active » Fixed

Thanks to fw_crocodile

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.