Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#20566 closed defect (bug) (fixed)

XML-RPC 3.4 methods cleanup

Reported by: nacin's profile nacin Owned by: nacin's profile nacin
Milestone: 3.4 Priority: high
Severity: normal Version: 3.4
Component: XML-RPC Keywords: has-patch commit
Focuses: Cc:

Description

Attached patch does the following:

  • Forces _prepare_taxonomy() and _prepare_post_type() to accept a post type or taxonomy object. (You arrays are not welcome here!)
  • Limits the return of _prepare_taxonomy() and _prepare_post_type() to a specific type-cast whitelist for things that are potentially useful for mobile apps. The type-casting is important as some arguments can be (or may be in the future) overloaded with arrays, strings, etc. Limiting is important for things like 'capability_type', which is used for registration only; 'rewrite', which can be overloaded and is not something that needs to be exposed to a client, etc. Forwards compatibility is very important to consider. (There is still a filter there, as well.)
  • Adds $filter and $fields to _prepare_taxonomy() and therefore wp_getTaxonomies, to match the functionality of wp_getPostTypes. fixes #20407.
  • Prevents post types from being changed in _insert_post(). Fixes #20475.
  • Removes post_type_supports() checks around comment_status, ping_status, and custom_fields. post_type_supports() handles the admin UI, but should not have any effect on the API. A post type not supporting custom fields (which I'd encourage) would otherwise not be able to have their metadata modified (sad panda).
  • Fixes sticky handling. The current code only allows published posts to be stickied. A post can be stickied as long as it is neither private nor password-protected. It now issues an error if the client tries to stick a private post; it will silently unstick a post that is stuck and then changed to be private/protected.
  • Unsets tags_input and post_category, as tax_input is also unset already.
  • Adds @since's, fixes some docs, trims trailing spaces. Uses rtrim() to remove then force Zulu onto timestamps rather than an str_replace().

With help from maxcutler.

Attachments (3)

20566.diff (20.2 KB) - added by nacin 13 years ago.
20566.phpdocs.patch (520 bytes) - added by SergeyBiryukov 13 years ago.
20566.xmlrpc-docs.diff (3.0 KB) - added by duck_ 13 years ago.

Download all attachments as: .zip

Change History (22)

@nacin
13 years ago

#1 @nacin
13 years ago

  • Keywords has-patch commit added

#2 @nacin
13 years ago

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

In [20632]:

Clean up the XML-RPC 3.4 methods with regards to consistency and future compatibility.

  • Limit returned taxonomy and post type objects to a specific type-cast whitelist of fields.
  • Add $filter and $fields to wp.getTaxonomies to match the functionality of wp.getPostTypes.
  • Prevent the post type from being chnaged in _insert_post().
  • Don't check post_type_supports() in _insert_post().
  • Align handling of sticky posts with those of core.
  • Force tags and categories to go through terms and terms_names, rather than tags_input and post_category.

fixes #20566. props nacin, maxcutler.

#4 @nacin
13 years ago

In [20635]:

Use correct variable. Caught by unit tests. see #20566.

#5 @SergeyBiryukov
13 years ago

20566.phpdocs.patch adds $fields parameter description for _prepare_taxonomy().

#6 @SergeyBiryukov
13 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#7 @nacin
13 years ago

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

In [20638]:

Add @param for the $fields parameter for XML-RPC's _prepare_taxonomy(). props SergeyBiryukov, fixes #20566.

#8 @batmoo
13 years ago

  • Cc batmoo@… added
  • Resolution fixed deleted
  • Status changed from closed to reopened

There are copy-paste errors in [20632]. Some of the GMT hackery changed the references of $content_struct['date_created_gmt'] to $post_data['post_date_gmt']. This is causing fatal errors:

Fatal error: Call to a member function getIso() on a non-object in /wp-includes/class-wp-xmlrpc-server.php

#9 @nacin
13 years ago

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

In [20664]:

Use correct variables. props batmoo. fixes #20566.

#10 @batmoo
13 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The array keys in [20664] are still incorrect; should be 'date_created_gmt'.

#11 @nacin
13 years ago

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

In [20665]:

Use correct variables. props batmoo. fixes #20566.

#12 @nacin
13 years ago

In [20670]:

Fix copy-paste issues in XML-RPC's _prepare_taxonomy(). see #20566.

#13 @nacin
13 years ago

In [20671]:

Kill all notices in XML-RPC found when running the test suite with WP_DEBUG. see [UT706], [UT707]. see #20566.

#14 @nacin
13 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#15 @nacin
13 years ago

We should resolve the discrepancy with _prepare_taxonomy() and _prepare_post_type() accepting 'capabilities', 'object_types', etc. but keying the data as 'cap' and 'object_type'. Since we are returning all data exactly how it is keyed in the taxonomy and post type objects, we should make the field groups named the same way.

#17 @nacin
13 years ago

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

#18 @duck_
13 years ago

In [20714]:

Declare visibility of _prepare_post_type() as protected. See #20566.

#19 @duck_
13 years ago

In [20782]:

Minor XML-RPC documentation improvements. See #20566.

Also make newly introduced _is_greater_than_one() private.

Note: See TracTickets for help on using tickets.