samtiria / nextgen-gallery

Automatically exported from code.google.com/p/nextgen-gallery
0 stars 0 forks source link

Hooks 'ngg_delete_gallery' and 'ngg_delete_picture' run too late #445

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a WP plugin that defines 'ngg_delete_gallery' and 
'ngg_delete_picture' hooks
2. Try to write code that acts on the deleted gallery or picture
3. Find that there is nothing left that is tied to the ID, because deletion of 
files and data has occurred before the hook is activated.

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

NGG 1.9.0, WP 3.2.1

Please provide any additional information below.

In admin/manage.php, two actions are called after deleting images and 
galleries: 'ngg_delete_picture' and 'ngg_delete_gallery'.

In both cases, the relevant IDs are passed. However, these hooks are called 
after the whole deletion process is completed, including removal of the picture 
or gallery from the database.

So, by the time any hooks are executed, you have an ID that doesn't mean 
anything anymore (everything related to it is gone), and there is no way to 
recover any information about the deleted items. That makes the hooks quite 
useless, from my point of view.

My request is to move both hooks upward a litte.

do_action('ngg_delete_picture', $this->pid)

should be called right after

$image = $nggdb->find_image( $this->pid );
if ($image) {

in function processor().

do_action('ngg_delete_gallery', $id);

should be called right after:

$gallery = nggdb::find_gallery($id);
if ($gallery){

in function post_processor_galleries().

Original issue reported on code.google.com by martijng...@gmail.com on 9 Dec 2011 at 8:25

GoogleCodeExporter commented 8 years ago
fixed in r1051

Original comment by alex.cologne on 10 Dec 2011 at 1:05