[wp-trac] [WordPress Trac] #29957: Hardcoded value of $chunk_size variable in class-IXR.php in wp-includes

WordPress Trac noreply at wordpress.org
Thu Oct 30 04:50:46 UTC 2014


#29957: Hardcoded value of $chunk_size variable in class-IXR.php in wp-includes
--------------------------+------------------------------
 Reporter:  ankit.gade@…  |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  XML-RPC       |     Version:  3.4
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  performance
--------------------------+------------------------------
Changes (by ankit.gade@…):

 * keywords:  has-patch reporter-feedback => has-patch


Comment:

 Replying to [comment:6 westi]:
 > Replying to [ticket:29957 ankit.gade@…]:
 > > Variable $chunk_size is used to restrict RAM usage to parse xml-rpc
 response message if the message is very large.
 > > This variable value has been hard coded to 262144 (256 Kb). A filter
 should be provided for setting value of this variable.
 > >
 > > It has following advantages.
 > >
 > > 1. If message is large around 4-5 Mb, then getResponse() method of
 IXR_Client returns null, we can avoid this situation by setting
 $chunk_size to higher value.
 > >
 > > 2. If server configuration is well versed, for example: If we have 32
 GB RAM on server then allotting 5-8 Mb to $chunk_size should not be an
 issue and for the same filter can be used.
 >
 > Hey, Ankit Gade can you explain these bugs in more detail with some
 examples.
 >
 > I'm not sure how change the chunk_size should affect the maximum
 response size that can be parsed.
 >
 > It would be good to have some test date / a unit test which shows how
 this bug can be reproduced.

 Hello Peter,

 Let me give you the scenario on which I am working currently and having
 such issue. Assume that we have two sites **A** and **B**, and I am
 currently working on site **A**.

 1. I am getting list of users present on site **B** using xml-rpc, the
 response message which I am getting is contains array of objects of users
 present on site **B** and the response message size is around 3 Mb. When I
 want to get that response in a variable using ''getresponse'' method of
 IXR_Client class, I am getting null. ( FYI, I have large value set for
 memory_limit in php.ini )

 2. Moreover, we have this piece of code in //parse// method of class
 **IXR_Message**
   {{{#!python
           do {
             if (strlen($this->message) <= $chunk_size) {
                 $final = true;
             }
             $part = substr($this->message, 0, $chunk_size);
             $this->message = substr($this->message, $chunk_size);
             if (!xml_parse($this->_parser, $part, $final)) {
                 return false;
             }
             if ($final) {
                 break;
             }
         } while (true);
   }}}

 If we have somewhat bigger $chunk_size set by filter ( In case we have
 good server resources ) then we can save the time we are iterating in do-
 while loop, since each time it will call functions it needs to to put
 arguments on stack etc.

 So, in this case we can parse the message in single iteration.

 Let me know if I am clear and in case you have any further query.

 Thanks

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29957#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list