Make WordPress Core

Opened 16 years ago

Closed 10 years ago

#7773 closed enhancement (fixed)

Duplicate enclosure attributes are created when a client resubmits a post with identical enclosure

Reported by: redsweater's profile redsweater Owned by: josephscott's profile josephscott
Milestone: 2.8 Priority: low
Severity: minor Version: 2.7
Component: XML-RPC Keywords: needs-patch
Focuses: performance Cc:

Description

The support in 2.6 for accepting enclosures via XMLRPC does not discriminate whether the specified enclosure is already attached to the post in question. This has the effect that if a client redundantly re-specifies the enclosure value, WordPress will redundantly add new enclosure custom field entries, each time the post is edited.

The code that accepts <enclosure> elements should only add a new custom field to the post if the enclosure specified is different from the previous enclosure(s). Arguably, for an XMLRPC context, the specified enclosure should always replace the (presumed singular) enclosure on the post.

Right now, the number of redundant enclosure attributes can spiral out of control depending on the number of times a given post is edited by a remote client that re-specifies all the known attributes of a post.

Consider for example, that when resubmitting a post, it's natural and expected to re-specifiy the <title> even if it hasn't changed. This doesn't cause multiple "title" attributes to appear on a post. The re-specification of the <enclosure> value shouldn't cause attribute bloat in posts.

Daniel

Daniel

Attachments (2)

7773.diff (1.8 KB) - added by Otto42 16 years ago.
First attempt at a patch
TakeTwo.diff (1.8 KB) - added by redsweater 15 years ago.
Revision of the initial patch.

Download all attachments as: .zip

Change History (12)

@Otto42
16 years ago

First attempt at a patch

#1 @Otto42
16 years ago

Added patch that should check through the enclosures and not re-add any that already exist in the post meta info.

#2 @redsweater
15 years ago

The patch provided was not quite working because the test for "!found" was missing the $ for the variable name.

I fixed the patch and also extracted the duplicated logic into a function add_enclosure_if_new().

I tested it with MarsEdit as a client and confirmed that the duplicate enclosures are no longer being created.

@redsweater
15 years ago

Revision of the initial patch.

#3 @Otto42
15 years ago

  • Keywords has-patch added
  • Version set to 2.7

#4 @westi
15 years ago

(In [10383]) Don't duplicate enclosures on edit. See #7773 props redsweater.

#5 @westi
15 years ago

Could possibly optimise to use get_post_meta rather than get_post_custom.

That would reduce the nesting a bit I think.

#6 @Denis-de-Bernardy
15 years ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from 2.8 to Future Release

Bumping the optimization to Future, pending patch...

#7 @Denis-de-Bernardy
15 years ago

  • Component changed from General to Optimization
  • Priority changed from normal to low
  • Severity changed from normal to minor

#8 @Denis-de-Bernardy
15 years ago

  • Milestone changed from Future Release to 2.9
  • Type changed from defect (bug) to enhancement

#9 @ryan
14 years ago

  • Milestone changed from 2.9 to Future Release

#10 @nacin
10 years ago

  • Component changed from Optimization to XML-RPC
  • Focuses performance added
  • Milestone changed from Future Release to 2.8
  • Resolution set to fixed
  • Status changed from new to closed

The original proposal here was done back in 2.8. Closing as fixed.

The straggling issue — using get_post_meta() instead — has since changed. That was me in [24623].

Note: See TracTickets for help on using tickets.