From e41d4b0d0caa233cf78ed3d50d67d50279689e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Calvo?= <rubencm@gmail.com> Date: Mon, 24 Jul 2017 09:37:10 +0200 Subject: [PATCH] [ticket/15287] Launch exception if storage is not available PHPBB3-15287 --- phpBB/language/en/common.php | 1 + phpBB/phpbb/storage/adapter_factory.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 1414f0fd1a..006582772a 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -727,6 +727,7 @@ $lang = array_merge($lang, array( 'SUBJECT' => 'Subject', 'SUBMIT' => 'Submit', + 'STORAGE_ADAPTER_NOT_AVAILABLE' => 'Selected storage is not available.', 'STORAGE_FILE_EXISTS' => 'File already exists.', 'STORAGE_FILE_NO_EXIST' => 'File does not exist.', 'STORAGE_CANNOT_WRITE_FILE' => 'Can not write to file.', diff --git a/phpBB/phpbb/storage/adapter_factory.php b/phpBB/phpbb/storage/adapter_factory.php index 429437ab28..85a3ef03f7 100644 --- a/phpBB/phpbb/storage/adapter_factory.php +++ b/phpBB/phpbb/storage/adapter_factory.php @@ -15,6 +15,7 @@ namespace phpbb\storage; use phpbb\config\config; use phpbb\di\service_collection; +use phpbb\storage\exception\exception; class adapter_factory { @@ -59,6 +60,11 @@ class adapter_factory $provider_class = $this->config['storage\\' . $storage_name . '\\adapter']; $provider = $this->providers->get_by_class($provider_class); + if (!$provider->is_available()) + { + throw new exception('STORAGE_ADAPTER_NOT_AVAILABLE'); + } + $adapter = $this->adapters->get_by_class($provider->get_adapter_class()); $adapter->configure($this->build_options($storage_name, $provider->get_options()));