WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 2 years ago

#24049 accepted defect (bug)

Make Plugin Editor's file list alphabetical by full path

Reported by: Daedalon Owned by: SergeyBiryukov
Milestone: Future Release Priority: normal
Severity: normal Version: 2.8
Component: Plugins Keywords: needs-unit-tests needs-patch
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 5 years ago.
ticket24049.diff (1.4 KB) - added by Daedalon 5 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 4 years ago.

Download all attachments as: .zip

Change History (13)

@Daedalon
5 years ago

@Daedalon
5 years ago

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

#1 @Daedalon
5 years ago

  • Keywords has-patch added
  • Version set to trunk

#2 @SergeyBiryukov
5 years ago

  • Version changed from trunk to 2.8

#3 @MattyRob
4 years ago

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

#4 @godhulii_1985
4 years ago

Please commit this patch. It works...

#5 @SergeyBiryukov
4 years ago

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

#6 @MattyRob
4 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
4 years ago

#7 @MattyRob
4 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
3 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
3 years ago

Vaguely related: #17552

#10 @chriscct7
2 years ago

  • Focuses administration added
Note: See TracTickets for help on using tickets.