$currentName = $this->config->get('storage', 'name', '');
- $this->currentBackend = $this->getByName($currentName);
+ // you can only use user backends as a "default" backend, so the second parameter is true
+ $this->currentBackend = $this->getByName($currentName, true);
}
/**
* @brief Return storage backend class by registered name
*
* @param string|null $name Backend name
- * @param boolean $userBackend Just return instances in case it's a user backend (e.g. not SystemResource)
+ * @param boolean $userBackend True, if just user specific instances should be returrned (e.g. not SystemResource)
*
* @return Storage\IStorage|null null if no backend registered at $name
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
- public function getByName(string $name = null, $userBackend = true)
+ public function getByName(string $name = null, $userBackend = false)
{
// If there's no cached instance create a new instance
if (!isset($this->backendInstances[$name])) {
*
* @return boolean True, if the backend is a valid backend
*/
- public function isValidBackend(string $name = null, bool $userBackend = true)
+ public function isValidBackend(string $name = null, bool $userBackend = false)
{
return array_key_exists($name, $this->backends) ||
(!$userBackend && $name === Storage\SystemResource::getName());
*/
public function setBackend(string $name = null)
{
- if (!$this->isValidBackend($name)) {
+ if (!$this->isValidBackend($name, false)) {
return false;
}
if ($this->config->set('storage', 'name', $name)) {
- $this->currentBackend = $this->getByName($name);
+ $this->currentBackend = $this->getByName($name, false);
return true;
} else {
return false;
{
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
- $this->assertEquals($userBackend, $storageManager->isValidBackend($name));
+ // true in every of the backends
+ $this->assertEquals(!empty($assertName), $storageManager->isValidBackend($name));
+
+ // if userBackend is set to true, filter out e.g. SystemRessource
+ $this->assertEquals($userBackend, $storageManager->isValidBackend($name, true));
}
/**