WordPress.org

Make WordPress Core

Opened 7 years ago

Last modified 10 months ago

#24049 accepted defect (bug)

Make Plugin Editor's file list alphabetical by full path

Reported by: Daedalon Owned by: SergeyBiryukov
Milestone: Priority: normal
Severity: normal Version: 2.8
Component: Plugins Keywords: close
Focuses: administration Cc:

Description

The files under Plugin Editor's (plugin-editor.php) Plugin Files header should be shown in alphabetical order of their full path. Currently their order seems completely random, which makes the list cumbersome to use.

Attachments (3)

24049.diff (385 bytes) - added by Daedalon 7 years ago.
ticket24049.diff (1.4 KB) - added by Daedalon 7 years ago.
Sorts file list alphabetically by full path and improves performance of get_plugin_files() by calling plugin_basename() only once
24049v2.diff (1.2 KB) - added by MattyRob 5 years ago.

Download all attachments as: .zip

Change History (14)

@Daedalon
7 years ago

@Daedalon
7 years ago

Sorts file list alphabetically by full path and improves performance of get_plugin_files() by calling plugin_basename() only once

#1 @Daedalon
7 years ago

  • Keywords has-patch added
  • Version set to trunk

#2 @SergeyBiryukov
7 years ago

  • Version changed from trunk to 2.8

#3 @MattyRob
6 years ago

I have tested this patch and it works fine for me. Commit?

#4 @godhulii_1985
5 years ago

Please commit this patch. It works...

#5 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 4.1
  • Owner set to SergeyBiryukov
  • Status changed from new to accepted

#6 @MattyRob
5 years ago

Sorry to report on further testing that this doesn't work fully.

By returning a sorted list of plugin files the 'first' entry returned may not be the main plugin file and it may also not be a file supported in the editor - resulting in unusual behaviour.

The sort needs to return the array with the main file at the start of the array or somehow that file needs to be 'selected' by default.

@MattyRob
5 years ago

#7 @MattyRob
5 years ago

Attached patch resolves the issued stated above by placing the main plugin file name at the start of the returned array.

I've also dropped the root file sorting section with the preg_match - it doesn't seem to change the returned values and also causes errors as the regex is not properly contained - I was getting lots of errors log about invalid operators.

#8 @johnbillion
5 years ago

  • Keywords needs-unit-tests needs-patch added; has-patch removed
  • Milestone changed from 4.1 to Future Release

If you select a file in a subdirectory for editing, the list of files in the sidebar completely breaks, and the current plugin is not correctly selected. I can't believe there isn't an existing ticket for this.

I think that's closely related to this and they should be fixed together. get_plugin_files() should probably always be passed the plugin's root file, not the file being currently edited.

We should also get some unit tests on this.

Related: #24048

#9 @dd32
5 years ago

Vaguely related: #17552

#10 @chriscct7
4 years ago

  • Focuses administration added

#11 @SergeyBiryukov
10 months ago

  • Keywords close added; needs-unit-tests needs-patch removed

This appears to be fixed in [41806], I can't reproduce any issues with file order in current trunk. The list includes:

  • The main plugin file.
  • The rest of the files, in alphabetical order.
Note: See TracTickets for help on using tickets.