Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#17127 closed enhancement (wontfix)

Must use plugins not displayed in order of execution

Reported by: jcnetsys's profile jcnetsys Owned by: jcnetsys's profile jcnetsys
Milestone: Priority: normal
Severity: trivial Version: 3.1
Component: Plugins Keywords: needs-patch 2nd-opinion
Focuses: Cc:

Description

From my testing it appears that MU plugins are executed in alphabetical order (with numbers before letters and symbols before that). It is therefore logical for the plugins to be displayed in this order in the WP admin panel which they are not - I will make a patch file.

Change History (5)

#1 @jcnetsys
14 years ago

  • Status changed from new to accepted

The problem is with

function _sort_uname_callback( $a, $b ) {
	return strnatcasecmp( $a['Name'], $b['Name'] );
}

Which doesn't do what it is supposed to as it returns elements which start with a symbol after those which start with a letter. Conventionally symbols are before letters in the alphabet and that is how they are executed.

#2 @jcnetsys
14 years ago

I have submitted a bug report with PHP regarding

strnatcasecmp

Until this is fixed it would be logical to use a custom function to sort.

#3 @dd32
14 years ago

  • Keywords 2nd-opinion added

If you want it to be sorted in the same order as the files are executed, you should be able to remove the sorting (and it'll fall back to the default order that the filesystem is returning).

However, for consistency sake with the other tables, I believe they should be ordered Alphabetically rather than in order of execution.

The plugins include order should not matter, as no plugin should be running code before plugins_loaded action or init action.. and the hook order there is not guaranteed based on the different execution paths of different patches.

#4 @scribu
14 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from accepted to closed

I agree with dd32: you shouldn't rely on the loading order.

The only guarantee you have is that must-use plugins will be loaded before normal plugins.

#5 @jcnetsys
14 years ago

I understand what you say and agree - what I would say is that it doesn't list them in alphabetical order (well not completely). My server is setup to return the files in alphabetical order (as is many) and it returns files that start with symbols first, then numbers then letters so '_file.php' is returned before '1file.php' which in turn is returned before 'afile.php'. This however is not the order that wordpress sorts things when doing it alphabetically as the above example would be returned in this order:

'1file.php', 'afile.php', '_file.php'

This is a global sorting problem - not just with the plugins.

The actual problem is with the php function 'strnatcasecmp' which wasn't designed to compare symbols.

And back to the 'you shouldn't rely on the loading order' - I totally agree but from a debugging point of view it makes it easier (in my opinion) to debug complex MU plugin setups if you can see the order they were executed in.

Last edited 14 years ago by jcnetsys (previous) (diff)
Note: See TracTickets for help on using tickets.