Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#15629 closed defect (bug) (wontfix)

Only support registered post formats in XML-RPC

Reported by: ericmann's profile ericmann Owned by: ericmann's profile ericmann
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: XML-RPC Keywords: has-patch needs-testing
Focuses: Cc:

Description

Currently, the XML-RPC interface assumes a default post format when the post format field is omitted in a create or update request. As a result, some users with external tools (like Live Writer) are seeing "default" tagged on their new posts.

We should only add the default post format if post formats are enabled for the site. We should also limit the XML-RPC interface such that it only adds post formats explicitly supported by the site's theme.

Attachments (1)

15629.diff (985 bytes) - added by ericmann 14 years ago.
Adds current_theme_supports() check to set_post_format().

Download all attachments as: .zip

Change History (11)

#1 follow-up: @nacin
14 years ago

  • Milestone changed from Awaiting Review to 3.1

This logic can probably go directly into set_post_format.

#2 in reply to: ↑ 1 @ericmann
14 years ago

Replying to nacin:

This logic can probably go directly into set_post_format.

Actually, that might be a more appropriate place. Then it would catch plug-ins trying to mark unsupported formats and not just external XML-RPC tools.

#3 @ryan
14 years ago

"default" is going into the DB. We should put nothing in the DB for the default format.

#4 @josephscott
14 years ago

On limiting to valid post format types, the existing code checks with get_post_format_strings() to see if it is a valid type.

#5 @josephscott
14 years ago

  • Cc josephscott added

#6 @westi
14 years ago

  • Cc westi added

@ericmann
14 years ago

Adds current_theme_supports() check to set_post_format().

#7 @ericmann
14 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

My first thought was to check if the current theme supports the post format being passed in to set_post_format(). This way, if a remote system tries to create a post with an unregistered post format, it won't add clutter to the database. To achieve this, I had to tweak current_theme_supports() to add a check for post-formats.

This should fix both the XML-RPC issue and any potential issues raised by other systems (i.e. plug-ins) trying to add unsupported post formats.

The patch is as yet untested ... but I wanted to make good on my promise to get a patch posted tonight :-)

#8 @nacin
14 years ago

Nice!

It looks like that code works the same as the post-formats branch. We should be able to just add the extra case there.

also, we should optionally return false, in set_post_format, if the theme doesn't support it, as the action failed.

In fact, all of these functions should noop.

Mark, maybe we should move these functions into a new file, and require_if_theme_support()? Seems odd to use it for thumbnails if we're not going to use them here.

#9 @josephscott
14 years ago

I think silently hiding errors is a bad idea. Chatted with others about this, I appear to be in the minority on this.

#10 @westi
14 years ago

  • Milestone 3.1 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

I think it seems best to always support them over XMLRPC like the code does at the moment.

So closing as WONTFIX

Note: See TracTickets for help on using tickets.