WordPress.org

Support

Support » Plugins and Hacks » Attachments » [Resolved] Errors thrown when deleting media library items

[Resolved] Errors thrown when deleting media library items

  • 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/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Errors thrown when deleting media library items’ is closed to new replies.
Skip to toolbar