[wp-trac] [WordPress Trac] #27365: Upgrader bulk_upgrade() functions do not return the correct data

WordPress Trac noreply at wordpress.org
Tue Mar 11 22:20:29 UTC 2014


#27365: Upgrader bulk_upgrade() functions do not return the correct data
-----------------------------+-----------------------------
 Reporter:  chrisbliss18     |      Owner:
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Upgrade/Install  |    Version:  trunk
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 In the bulk_upgrade() function of Language_Pack_Upgrader, Plugin_Upgrader,
 and Theme_Upgrader the values returned are not set properly, resulting in
 very poor feedback from the function on success or failure.

 For instance, take the following code sample from Plugin_Upgrader:

 {{{#!php
 $result = $this->run( array(
     'package' => $r->package,
     'destination' => WP_PLUGIN_DIR,
     'clear_destination' => true,
     'clear_working' => true,
     'is_multi' => true,
     'hook_extra' => array(
         'plugin' => $plugin
     )
 ) );

 $results[$plugin] = $this->result;
 }}}

 Notice how the result is stored in the `$result` variable yet the
 `$results` variable, which is used as the return value, stores the
 `$this->result` variable. While the `$this->result` variable does contain
 some data, it's not very relevant as a return value for these functions.
 This issue causes a loss of most, if not all error feedback (I have yet to
 test every possible combination of result possibilities) and fails to
 provide any useful success condition responses. In most of my test cases,
 this issue results in each package having a response value of `null`.

 This same issue can be found in the Language_Pack_Upgrader and
 Theme_Upgrader classes.

 My solution is to simply change `$this->result` to `$result` as found in
 the supplied patch and as shown below:

 {{{#!php
 $results[$plugin] = $result;
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27365>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list