Support » Plugin: CyberSEO Lite (CyberSyn) » Bug detected

  • Resolved rovowp

    (@rovowp)


    Good afternoon, CyberSEO team! Found a bug with deleting pictures from posts during certain manipulations:

    1. Open the post editing page
    2. Add image to post
    3. Save/update post
    4. Open “Preview Changes”
    5. On the post editing page press ctrl+f5

    The original image is permanently deleted.

    If it doesn’t work the first time, repeat the steps 4 and 5

    Tested on different versions WP.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author CyberSEO

    (@cyberseo)

    How exactly the image must be added to reproduce this situation?

    With button “Add media”, i use Classic Editor

    Plugin Author CyberSEO

    (@cyberseo)

    And how this operation is related to CyberSEO? Sorry, but I didn’t get it.

    See call stack: https://ibb.co/N2kxkZg

    Plugin Author CyberSEO

    (@cyberseo)

    You have deleted the post revision, so the image was removed as well. Your WP editor calls delete_post_revision(), which calls delete_post(). It triggers CyberSyn which check if this post was created by it. Course it deletes the pictures, because we must be sure there are no junk when post is deleted.

    You may avoid it by removing of the following line, but I won’t recommend you doing that:

    add_action('before_delete_post', 'csyn_delete_post_images');

    Here is the official description of before_delete_post() from https://codex.wordpress.org/Plugin_API/Action_Reference/before_delete_post:

    It’s important to note the hook runs only when the WordPress user empties the Trash. If you’re using this hook note that it will not fire if the user is deleting an Attachment, since attachments are force deleted, i.e., not sent to the Trash. Instead use the delete_post() hook.

    So this is not a bug. This is a feature.

    In fact, it is not clear why this code generally works with these manipulations. I intentionally do not delete anything.

    Ok, understood, feature so feature 🙂

    May be a better solution is hook – remove_action(‘before_delete_post’, ‘csyn_delete_post_images’); in functions.php? This will allow to safely update the plugin.

    Plugin Author CyberSEO

    (@cyberseo)

    No. After the update the function will be added again. You are the only one of my customers who wants the plugin to work without it. If I delete in in the official version, there will be a lot of people who will write here about another “bug: when you delete a post, the images are staying on server.

    I understand that this is a double-edged sword, but i meant that adding a hook would be a more universal solution for me, because plugin files with this approach remain untouched.

    Perhaps it will be convenient to add this option (store / delete images) using the switch?

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.