WordPress.org

Ready to get started?Download WordPress

Forums

Attachments
[resolved] Errors thrown when deleting media library items (3 posts)

  1. bigmikestudios
    Member
    Posted 8 months ago #

    When deleting media items from the library, I found errors were thrown by line 136 of class.attachments.search.php and line 1544 of class.attachments.php.

    I've written in the following hacks, and they seem to restore my ability to delete media items, at least for now:

    ////////////////

    To prevent an error being thrown when a foreach loop was given a non-array object to loop through when media items are deleted, I added this at line 136 of class.attachments.search.php:

    // HACK! - throws an error if $potential_attachments[$i]->fields is not an array.
    if ( !(is_array($potential_attachments[$i]->fields)) ) $potential_attachments[$i]->fields = array($potential_attachments[$i]->fields);
    // END HACK

    ////////////////

    To prevent an error being thrown when a object is encountered instead of an array, I added this at line 1544 of class.attachments.php:

    /* HACK! */
    $attachment = (is_array($attachment)) ? $attachment : (array)$attachment;
    /* END HACK! */

    http://wordpress.org/plugins/attachments/

  2. Jonathan Christopher
    Member
    Plugin Author

    Posted 7 months ago #

    Thank you for this report, this looks to be related to http://wordpress.org/support/topic/variable-type-mismach-error-during-delete-of-media-item?replies=2 and a fix will be included in the next release.

  3. Jonathan Christopher
    Member
    Plugin Author

    Posted 6 months ago #

    Version 3.5.2 should resolve this issue, if it didn't we can definitely reopen this.

Reply

You must log in to post.

About this Plugin

About this Topic