[wp-trac] [WordPress Trac] #50849: Incorrect action passed to hooks when updating plugin/theme by uploading ZIP file

WordPress Trac noreply at wordpress.org
Wed Oct 21 22:26:18 UTC 2020


#50849: Incorrect action passed to hooks when updating plugin/theme by uploading
ZIP file
-------------------------------------+---------------------
 Reporter:  desrosj                  |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  5.5.2
Component:  Upgrade/Install          |     Version:  5.5
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+---------------------

Comment (by hellofromTonya):

 In the [https://core.trac.wordpress.org/attachment/ticket/50849/50849.diff
 patch], the same code is repeated twice. That makes it less maintainable
 as any future changes must be made in both places.

 Both of these classes are extending off of `WP_Upgrader`. The code can be
 abstracted to the base class as a `protected method`. Then it's available
 for both the theme and plugin classes to directly invoke that new method.

 Maybe something like this in the `WP_Upgrader` class:

 {{{#!php
 <?php
 protected function get_hook_extra_action_type() {
         if (
                 ! empty( $this->skin->overwrite )
                 &&
                 in_array( $this->skin->overwrite, array( 'update-theme',
 'downgrade-theme' ), true )
         ) {
                 return $this->skin->overwrite;
         }

         return 'install';
 }
 }}}

 What do you think @desrosj?

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


More information about the wp-trac mailing list