PluginManager: check graylist before doing any loadability checks

fixes #5087
This commit is contained in:
Dylan K. Taylor 2022-06-02 16:29:22 +01:00
parent c87a3b054c
commit 4b662d65b3
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -270,6 +270,17 @@ class PluginManager{
$name = $description->getName();
if($this->graylist !== null && !$this->graylist->isAllowed($name)){
$this->server->getLogger()->notice($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_loadError(
$name,
$this->graylist->isWhitelist() ? KnownTranslationFactory::pocketmine_plugin_disallowedByWhitelist() : KnownTranslationFactory::pocketmine_plugin_disallowedByBlacklist()
)));
//this does NOT increment loadErrorCount, because using the graylist to prevent a plugin from
//loading is not considered accidental; this is the same as if the plugin were manually removed
//this means that the server will continue to boot even if some plugins were blocked by graylist
continue;
}
if(($loadabilityError = $loadabilityChecker->check($description)) !== null){
$this->server->getLogger()->critical($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_loadError($name, $loadabilityError)));
$loadErrorCount++;
@ -286,17 +297,6 @@ class PluginManager{
$this->server->getLogger()->warning($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_spacesDiscouraged($name)));
}
if($this->graylist !== null && !$this->graylist->isAllowed($name)){
$this->server->getLogger()->notice($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_loadError(
$name,
$this->graylist->isWhitelist() ? KnownTranslationFactory::pocketmine_plugin_disallowedByWhitelist() : KnownTranslationFactory::pocketmine_plugin_disallowedByBlacklist()
)));
//this does NOT increment loadErrorCount, because using the graylist to prevent a plugin from
//loading is not considered accidental; this is the same as if the plugin were manually removed
//this means that the server will continue to boot even if some plugins were blocked by graylist
continue;
}
$triage->plugins[$name] = new PluginLoadTriageEntry($file, $loader, $description);
$triage->softDependencies[$name] = array_merge($triage->softDependencies[$name] ?? [], $description->getSoftDepend());