diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php index a59993a..2dd38a5 100644 --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php @@ -257,8 +257,7 @@ public function listAll($prefix = '') { ), $this->options)->fetchCol(); } catch (\Exception $e) { - // Convert any errors to the expected exception. - throw new StorageException($e->getMessage(), 0, $e); + return array(); } } @@ -273,8 +272,7 @@ public function deleteAll($prefix = '') { ->execute(); } catch (\Exception $e) { - // Convert any errors to the expected exception. - throw new StorageException($e->getMessage(), 0, $e); + return FALSE; } } } diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php index 14268e9..4281df2 100644 --- a/core/lib/Drupal/Core/Config/FileStorage.php +++ b/core/lib/Drupal/Core/Config/FileStorage.php @@ -213,7 +213,7 @@ public function listAll($prefix = '') { // glob() silently ignores the error of a non-existing search directory, // even with the GLOB_ERR flag. if (!file_exists($this->directory)) { - throw new StorageException($this->directory . '/ not found.'); + return array(); } $extension = '.' . static::getFileExtension(); // \GlobIterator on Windows requires an absolute path. diff --git a/core/lib/Drupal/Core/Config/StorageInterface.php b/core/lib/Drupal/Core/Config/StorageInterface.php index 09cc032..f4a85ea 100644 --- a/core/lib/Drupal/Core/Config/StorageInterface.php +++ b/core/lib/Drupal/Core/Config/StorageInterface.php @@ -131,9 +131,6 @@ public function decode($raw); * * @return array * An array containing matching configuration object names. - * - * @throws \Drupal\Core\Config\StorageException - * If there is an error accessing the storage. */ public function listAll($prefix = ''); @@ -153,9 +150,6 @@ public function listAll($prefix = ''); * * @return boolean * TRUE on success, FALSE otherwise. - * - * @throws \Drupal\Core\Config\StorageException - * If there is an error accessing the storage. */ public function deleteAll($prefix = ''); diff --git a/core/modules/config/lib/Drupal/config/Tests/Storage/ConfigStorageTestBase.php b/core/modules/config/lib/Drupal/config/Tests/Storage/ConfigStorageTestBase.php index 140b50a..74df325 100644 --- a/core/modules/config/lib/Drupal/config/Tests/Storage/ConfigStorageTestBase.php +++ b/core/modules/config/lib/Drupal/config/Tests/Storage/ConfigStorageTestBase.php @@ -95,6 +95,10 @@ function testCRUD() { $result = $this->invalidStorage->read($name); $this->assertIdentical($result, FALSE); + // Listing on a non-existing storage bin returns an empty array. + $result = $this->invalidStorage->listAll(); + $this->assertIdentical($result, array()); + // Deleting all names with prefix deletes the appropriate data and returns // TRUE. $files = array( @@ -131,16 +135,6 @@ function testCRUD() { $this->pass($class . ' thrown upon deleting from a non-existing storage bin.'); } - // Listing on a non-existing storage bin throws an exception. - try { - $this->invalidStorage->listAll(); - $this->fail('Exception not thrown upon listing from a non-existing storage bin.'); - } - catch (\Exception $e) { - $class = get_class($e); - $this->pass($class . ' thrown upon listing from a non-existing storage bin.'); - } - // Test renaming an object that does not exist throws an exception. try { $this->storage->rename('config_test.storage_does_not_exist', 'config_test.storage_does_not_exist_rename');