Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#29169 closed defect (bug) (fixed)

Scan for lost attachments: $lost is lost

Reported by: afercia's profile afercia Owned by: ocean90's profile ocean90
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.1
Component: Media Keywords: has-patch commit
Focuses: Cc:

Description

in Media Library > Unattached > Scan for lost attachments
press the button, nothing happens.
There have been so many changes to upload.php and class-wp-media-list-table.php and now, even if the $lost query finds something, there's a redirect and $lost is null after the redirect.
Moreover, looks like there's nothing left in the code to actually display lost attachments.
I'm not sure there's still a real use case for this scan, I had to manually edit the DB to have a media file attached to a no longer existing posts since wp_delete_post() "Points all attachments to the deleted post up one level".
See #10911 for some background.

Attachments (3)

29169.patch (1.2 KB) - added by SergeyBiryukov 12 years ago.
29169.2.patch (3.0 KB) - added by ocean90 11 years ago.
29169.3.patch (2.9 KB) - added by ocean90 11 years ago.

Download all attachments as: .zip

Change History (12)

#1 @SergeyBiryukov
12 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 4.0
  • Version changed from 3.9.1 to 3.1

Wow. Broken 4 years ago in [15491] (see #14579). Was altered in [15642], but never fixed.

29169.patch seems to work for me.

#2 @afercia
12 years ago

hi Sergey, thx very much.
For me, it doesn't work. It gets the query arg and that's ok but then wp_edit_attachments_query() returns 0 posts because $q['detached'] is still set.

http://i.imgur.com/wtx9bXz.png

When detached is set, wp_edit_attachments_query() sets 'post_parent' to 0 so it excludes my lost attachment which has a post_parent > 0.
If I'm not wrong, scan for lost attachment was intended for media attached to no longer existing posts but with (for any reasons) post_parent > 0 which is different from "Unattached" media that normally have post_parent = 0.
Adding to your patch unset( $q['detached'] ); together with $q['post__in'], then it works but I'm not 100% sure, there may be better ways.

#3 @azaozz
11 years ago

If I remember right "Scan for lost attachments" was added as a "way out" for users to recover gallery posts deleted before version 2.5 (or maybe earlier). If it hasn't been working for 4 years and nobody noticed, maybe it's time to retire it :)

#4 @helen
11 years ago

I agree, let's kill it.

This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.


11 years ago

@ocean90
11 years ago

@ocean90
11 years ago

#6 @ocean90
11 years ago

29169.3.patch removes the non-functional feature.

#7 @helen
11 years ago

  • Keywords commit added

Looks good to me.

#8 @ocean90
11 years ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from new to closed

In 29550:

Media: Remove scan for lost attachments.

This hasn't been worked for 4 years.

fixes #29169.

#9 @nacin
11 years ago

Wow. Well then. :)

Note: See TracTickets for help on using tickets.