Make WordPress Core

Ticket #22287: 22287.diff

File 22287.diff, 962 bytes (added by pbiron, 4 years ago)
  • src/wp-admin/includes/class-plugin-upgrader.php

    diff --git a/src/wp-admin/includes/class-plugin-upgrader.php b/src/wp-admin/includes/class-plugin-upgrader.php
    index c750399277..14b1c89754 100644
    a b class Plugin_Upgrader extends WP_Upgrader { 
    496496                // Assume the requested plugin is the first in the list.
    497497                $pluginfiles = array_keys( $plugin );
    498498
     499                usort( $pluginfiles, array( $this, '_plugin_info_sort_comparison' ) );
     500
    499501                return $this->result['destination_name'] . '/' . $pluginfiles[0];
    500502        }
    501503
     504        /**
     505         * Internal function for comparing paths to sort plugin files in no directory to the top.
     506         *
     507         * @param  string $plugin_file_a
     508         * @param  string $plugin_file_b
     509         * @return int
     510         */
     511        function _plugin_info_sort_comparison( $plugin_file_a, $plugin_file_b ) {
     512                return strstr( $plugin_file_a, '/' ) ? 1 : -1;
     513        }
     514
    502515        /**
    503516         * Deactivates a plugin before it is upgraded.
    504517         *