Gallery crashes when revision is deleted
-
Hi.
I’ve been using your NextGen Gallery plugin to create galleries for a while, and it works just fine. But I also use Better Delete Revision plugin (https://www.ads-software.com/plugins/better-delete-revision) to remove revisions. After I delete the revisions of the post that features the gallery – it is immediately crashes and a message ‘Invalid Displayed Gallery’ appears. When I delete other posts’ revisions that do not contain a gallery, nothing crashes and everything works as it’s supposed to. Also, this problem does not appear if a gallery is displayed via the shortcode.
I honestly tried to figure out what the problem is myself. If I create a gallery through the button in the TinyMCE editor, then a post with post_type = displayed_gallery is created in the wp_posts chart, featuring the data that, as far as I understand, is essential for the gallery display. I checked the Better Delete Revision plugin code, and its work seems simple and correct. It uses built-in WordPress functions, such as:wp_delete_post_revision:
$bdr_revisions = $wpdb->get_results(
“SELECTID
AS revision_id
FROM ($wpdb->posts)
WHEREpost_type
= ‘revision’
ORDER BYID
DESC”
);
foreach ( $bdr_revisions as $bdr_revision ) {
wp_delete_post_revision( $bdr_revision->revision_id );
}Then I examined the function wp_delete_post_revision and saw that this function trigger the following function – wp_delete_post( $revision->ID ). The function wp_delete_post features a hook o_action( ‘after_delete_post’, $postid ). Then I checked your plugin’s file wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/attach_to_post/module.attach_to_post.php and in the line 131 I saw that there is a connection to this hook – add_action(‘after_delete_post’, array(&$this, ‘cleanup_displayed_galleries’));
which triggers the following function:
cleanup_displayed_galleries()
function cleanup_displayed_galleries($post_id)
{
global $displayed_galleries_to_cleanup;
$mapper = $this->get_registry()->get_utility(‘I_Displayed_Gallery_Mapper’);
foreach ($displayed_galleries_to_cleanup as $id) $mapper->destroy($id);
}As $post_id parameter a post id from the post_type = displayed_gallery (which I’ve mentioned above) is transmitted. This is where the gallery featured in this post gets deleted.
I find it not exactly right that NextGen Gallery does not check what is deleted – the post or its revision, especially given that they have different id-s and post_type in the database.
Sadly, I am not that good at programming, so I have no idea how to fix this. Can you please get onto this problem and fix it?
Thanks in advance.
- The topic ‘Gallery crashes when revision is deleted’ is closed to new replies.