WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#6840 closed defect (bug) (fixed)

Stale enclosures are not removed if post is edited.

Reported by: my_user_name_was_not_valid Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.5
Component: Feeds Keywords: 2nd-opinion has-patch needs-testing enclosures
Focuses: Cc:

Description

The only way to remove enclosures is to delete them from the postmeta table by hand. If you change a url on a enclosure the rss/atom feeds would now show both new and old enclosure urls even though there is only one enclosure. I am attaching a patch that adds a foreach loop to the do_enclose function in wp-includes/functions.php that deletes enclosures from the metapost table that are no longer in the post.

Attachments (2)

fix_stale_enclosures.patch (758 bytes) - added by my_user_name_was_not_valid 6 years ago.
fix_stale_enclosures-rebased.patch (1.1 KB) - added by mystyman 5 years ago.
re-based to revision 11274, adjusted inline documentation

Download all attachments as: .zip

Change History (21)

comment:1 my_user_name_was_not_valid6 years ago

  • Version set to 2.5

comment:2 my_user_name_was_not_valid6 years ago

  • Keywords enclosures added

comment:3 my_user_name_was_not_valid6 years ago

  • Keywords has-patch added
  • Resolution set to fixed
  • Status changed from new to closed

comment:4 my_user_name_was_not_valid6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:5 ryan6 years ago

  • Milestone changed from 2.5.2 to 2.9

Milestone 2.5.2 deleted

comment:6 ryan5 years ago

  • Component changed from General to Feeds

comment:7 ryan5 years ago

  • Milestone changed from 2.9 to 2.8

comment:8 Denis-de-Bernardy5 years ago

  • Keywords needs-patch added; has-patch removed

broken patch

comment:9 mystyman5 years ago

  • Keywords has-patch added; needs-patch removed

Hi, I have verified that this bug exists and i have rebased the old patch to a current svn revision 11181 and tested it briefly, it appears to be working. I've attached it (fix_stale_enclosures-rebased.patch)

comment:10 Denis-de-Bernardy5 years ago

  • Keywords reporter-feedback added

shouldn't the query be meta_value = %s, rather than like (%s)?

comment:11 mystyman5 years ago

meta_value = %s wont work because the url wont match exact since the meta_value also contains the length and the type appended to it separated by newlines. An example meta_value:

http://podcasts.example.com/some.mp3
3133986
audio/mpeg

And since we don't know the length and mine type at this point in the code we can't match them, hence the LIKE

comment:12 Denis-de-Bernardy5 years ago

  • Keywords needs-testing added; reporter-feedback removed

comment:13 follow-up: Denis-de-Bernardy5 years ago

  • Keywords 2nd-opinion added

could this code not be placed over at in wp_update_post or something like that?

comment:14 in reply to: ↑ 13 mystyman5 years ago

Replying to Denis-de-Bernardy:

could this code not be placed over at in wp_update_post or something like that?

I can't figure out how to put this functionality in wp_update_post without some major re-factoring of how enclosures are handled. Plus it makes since (to me at least) to do all the enclosure stuff in the do_enclose function. Is there a specific reason why you don't like it where it is, or a specific place where you think it would be better placed?

comment:15 Denis-de-Bernardy5 years ago

no specific reason, I was merely wondering. it seems natural to ensure that enclosures are correct upon saving the post, but as you highlight it's already done with somewhere else.

mystyman5 years ago

re-based to revision 11274, adjusted inline documentation

comment:16 ryan5 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [11315]) Remove stale enclosures. Props mystyman. fixes #6840

comment:17 windyweather5 years ago

  • Cc windyweather added
  • Resolution fixed deleted
  • Status changed from closed to reopened

I'm still seeing this problem in 2.8.2. Unless the last function performed is "Add Custom Field", for something like Slippery 1, the custom field disappears. Each time the post is updated, the custom field disappears. I have set the default theme and disabled all plugins and the custom fields still disappear. I'm going to reopen based on this behavior.

comment:18 windyweather5 years ago

  • Cc windyweather removed

Sorry... this is the old bug. I see that the new one is #10511. Sorry.

comment:19 Denis-de-Bernardy5 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.