mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 11:27:07 +00:00
On most filesystems, plugins are loaded in lexical order because that's how the filesystem gives the files to us. This is a problem because it can hide bugs with dependency resolution on specific platforms with this behaviour, while inexplicably breaking on other platforms where the load order is different or undefined. This change prevents plugins depending on any file yield order by randomizing the order in which plugin files are checked for loadability.
This commit is contained in:
parent
cf538afb84
commit
025b72e2f2
@ -55,7 +55,9 @@ use function is_bool;
|
||||
use function is_dir;
|
||||
use function is_string;
|
||||
use function is_subclass_of;
|
||||
use function iterator_to_array;
|
||||
use function mkdir;
|
||||
use function shuffle;
|
||||
use function stripos;
|
||||
use function strpos;
|
||||
use function strtolower;
|
||||
@ -236,12 +238,11 @@ class PluginManager{
|
||||
}else{
|
||||
$loaders = $this->fileAssociations;
|
||||
}
|
||||
|
||||
$files = iterator_to_array(new \FilesystemIterator($directory, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS));
|
||||
shuffle($files); //this prevents plugins implicitly relying on the filesystem name order when they should be using dependency properties
|
||||
foreach($loaders as $loader){
|
||||
foreach(new \DirectoryIterator($directory) as $file){
|
||||
if($file === "." or $file === ".."){
|
||||
continue;
|
||||
}
|
||||
$file = $directory . $file;
|
||||
foreach($files as $file){
|
||||
if(!$loader->canLoadPlugin($file)){
|
||||
continue;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user