From 94352782d5aa846de3f8da186d68a3ddc4cd9a71 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 26 Jul 2018 10:31:57 +0100 Subject: [PATCH 1/3] https://media.giphy.com/media/UAUtB4Oi9U4EM/giphy.gif --- src/pocketmine/plugin/PluginManager.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index a592197f4..16bdfdb8a 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -663,9 +663,6 @@ class PluginManager{ $this->plugins = []; $this->enabledPlugins = []; $this->fileAssociations = []; - $this->permissions = []; - $this->defaultPerms = []; - $this->defaultPermsOp = []; } /** From 08be51dc23f627c1cb333786e8e35953a702e7df Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 26 Jul 2018 10:40:28 +0100 Subject: [PATCH 2/3] Clear permissions on server reload --- src/pocketmine/Server.php | 1 + src/pocketmine/permission/PermissionManager.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 3ee7a1e04..7caf08906 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1963,6 +1963,7 @@ class Server{ $this->pluginManager->disablePlugins(); $this->pluginManager->clearPlugins(); + PermissionManager::getInstance()->clearPermissions(); $this->commandMap->clearCommands(); $this->logger->info("Reloading properties..."); diff --git a/src/pocketmine/permission/PermissionManager.php b/src/pocketmine/permission/PermissionManager.php index 5812cce01..b1a701164 100644 --- a/src/pocketmine/permission/PermissionManager.php +++ b/src/pocketmine/permission/PermissionManager.php @@ -212,4 +212,10 @@ class PermissionManager{ public function getPermissions() : array{ return $this->permissions; } + + public function clearPermissions() : void{ + $this->permissions = []; + $this->defaultPerms = []; + $this->defaultPermsOp = []; + } } From 9a423be1db61fc229591c1bea109d9fa417c542d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 26 Jul 2018 12:34:14 +0100 Subject: [PATCH 3/3] Internet: Throw more specific exceptions RuntimeException is very generic and might be thrown for other reasons apart from web request failures. This is backwards compatible because InternetException is a descendent of RuntimeException. Additionally, getURL() and postURL() have intentionally been left untouched for backwards compatibility's sake. --- src/pocketmine/utils/Internet.php | 6 ++--- src/pocketmine/utils/InternetException.php | 28 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 src/pocketmine/utils/InternetException.php diff --git a/src/pocketmine/utils/Internet.php b/src/pocketmine/utils/Internet.php index 292f269ca..093b3b94f 100644 --- a/src/pocketmine/utils/Internet.php +++ b/src/pocketmine/utils/Internet.php @@ -131,11 +131,11 @@ class Internet{ * * @return array a plain array of three [result body : string, headers : array[], HTTP response code : int]. Headers are grouped by requests with strtolower(header name) as keys and header value as values * - * @throws \RuntimeException if a cURL error occurs + * @throws InternetException if a cURL error occurs */ public static function simpleCurl(string $page, $timeout = 10, array $extraHeaders = [], array $extraOpts = [], callable $onSuccess = null){ if(!self::$online){ - throw new \RuntimeException("Cannot execute web request while offline"); + throw new InternetException("Cannot execute web request while offline"); } $ch = curl_init($page); @@ -157,7 +157,7 @@ class Internet{ $raw = curl_exec($ch); $error = curl_error($ch); if($error !== ""){ - throw new \RuntimeException($error); + throw new InternetException($error); } $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); diff --git a/src/pocketmine/utils/InternetException.php b/src/pocketmine/utils/InternetException.php new file mode 100644 index 000000000..bc93512b0 --- /dev/null +++ b/src/pocketmine/utils/InternetException.php @@ -0,0 +1,28 @@ +