[wp-trac] [WordPress Trac] #6612: Problems with setting XML-RPC date using metWeblog.newPost()

WordPress Trac wp-trac at lists.automattic.com
Sat Aug 15 10:02:26 UTC 2009


#6612: Problems with setting XML-RPC date using metWeblog.newPost()
-------------------------------+--------------------------------------------
 Reporter:  Da_fonz            |        Owner:  anonymous
     Type:  defect (bug)       |       Status:  reopened 
 Priority:  normal             |    Milestone:           
Component:  XML-RPC            |      Version:  2.8.4    
 Severity:  normal             |   Resolution:           
 Keywords:  reporter-feedback  |  
-------------------------------+--------------------------------------------
Changes (by effectivemarketing):

 * cc: effectivemarketing (added)
  * status:  closed => reopened
  * version:  => 2.8.4
  * resolution:  invalid =>


Comment:

 This is tested and is definitely an issue, and I therefore request that
 the ticket is re-opened.

 When enabling error reporting, the following error occurs when using the
 "metaWeblog.newPost" function:

 '''PHP Fatal error:  Call to a member function getIso() on a non-object in
 /var/www/xmlrpc.php on line 2187'''

 To verify, create the following test file in the same directory as
 xmlrpc.php:


 {{{
 <?php

   include_once('wp-includes/class-IXR.php');

   $url = 'http://www.yourdomain.com/xmlrpc.php';
   $user = 'admin';
   $pass = 'password';

   $client = new IXR_Client($url);

   $client->query('metaWeblog.newPost', 1, $user, $pass,
                  array('post_status' => 'draft',
                        'title' => 'Date Set Test Post',
                        'description' => 'Test Post',
                        'dateCreated' => '20090815T10:00:00Z', 1);

   $res = $client->getResponse();

   if ($res) {
     print "Post #$res added successfully<br>\n";
   } else {
     print "Post not added<br>\n";
   }

 ?>
 }}}

 Obviously change the $url, $user and $pass to your server details.

 With an unpatched xmlrpc.php, the above will fail and return "'''Post not
 added'''".

 The problem is the following code:

 '''{{{$dateCreated = $content_struct['dateCreated']->getIso();}}}'''

 {{{$content_struct['dateCreated']}}} is a string, yet an object method is
 applied.

 To fix, simply remove all occurrences of "'''->getIso()'''" from
 xmlrpc.php. When done, the above test code will return "'''Post #xxx added
 successfully'''"

 One more issue: in the same section you will find use of the constant GMT:

 {{{
 $post_date_gmt = iso8601_to_datetime($dateCreated, GMT);
 }}}

 However, it is not defined anywhere as a constant and PHP does an implicit
 conversion. This should be amended to use a string constant instead:

 {{{
 $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
 }}}

 The enclosed patch corrects xmlrpc.php for both these issues.

 Note: The same problem exists in wp_editComment and mw_editPost and have
 been corrected in the patch, but I have not tested these.

 I have also reported this on my site at
 [http://www.effectivemarketingtenerife.com/technical/wordpress-xmlrpc-
 datecreated-bug-not-fixed/]

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/6612#comment:6>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list