[wp-trac] [WordPress Trac] #25089: XML-RPC server wrongly conflates post_status "future" with "publish"
WordPress Trac
noreply at wordpress.org
Tue Aug 20 04:50:53 UTC 2013
#25089: XML-RPC server wrongly conflates post_status "future" with "publish"
--------------------------+-----------------------------
Reporter: kailasa | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: XML-RPC | Version:
Severity: major | Keywords:
--------------------------+-----------------------------
Word Press Core:
/wp-includes/class-wp-xmlrpc-server.php
is broadcasting "future" as "publish" with this code
{{{
// Consider future posts as published
if ( $post_fields['post_status'] === 'future' )
$post_fields['post_status'] = 'publish';
}}}
this presents a problem for someone who really needs to use XMLRPC to talk
to the wp database (via wp.getPosts/WP_QUERY et al....) and distinguish
between published posts and scheduled posts.
In a real media world (of books and magazines, articles, PHD dissertations
etc.) "Published" means "Now available to the public."
I can't really understand why this decision was made and would consider it
a bad one. I suppose the author that file is thinking "OK the post is done
and ready to go... it's just waiting for the clock to roll around... so it
is effectively published." But this just shows ignorance or lack of
experience in the real world of media distribution.
If a variable in a framework has 8 discreet assigned values by default,
they are there, separate and distinct, for very good reasons. Future is
*not* publish. The former does not appear on the blog, the latter does...
they are different.
The core code should not be making decisions to override these
distinctions and force developers to "unconflate" two values that someone
had the not-so-bright idea to make equal.
wp.getPosts has a filter struct as one optional paramater... I should be
free to pass "post_type:POST; post_status:future" as a filter so that my
wp.getPosts requests only return posts with a time of now/today or earlier
(i.e. post_status not equal to "future")
We have two options. We can either get all posts and then in our LiveCode
web app framework (revIgniter) write a routine to parse them all for some
date range to ignore all that are in the future. This a horrible
hack...and will eat CPU...
OR the other option is we hack the core and comment out the offending two
lines in
/wp-includes/class-wp-xmlrpc-server.php
(which I have done for now)
But of course, we then break the Golden Rule "Don't Hack The Core!" and
must remember to keep copies of our version of class-wp-xmlrpc-server.php
to replace the one that comes in on upgrade... but of course this is
really bad, because perhaps the next upgrade to WP has major changes to
the class-wp-xmlrpc-server.php...We all know this is not best
practices....
So I'm forced to go in after each upgrade and comment out the silly
decision to tell the world that "consider bananas (future) equal to apples
(publish)"
Please remove that code from
/wp-includes/class-wp-xmlrpc-server.php
this opens the door to a feature request to make the XML-RPC framework
customizable and extensible. I will submit that as a separate ticket but
refer back to this issue. (if some developer would like "future" to be
equated with "publish"... ok, fine, but that should be a "theme" option.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25089>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list