Compare commits

...

2 Commits

Author SHA1 Message Date
Robin Appelman 70ae096563
use eq instead of in for loading single storage
Signed-off-by: Robin Appelman <robin@icewind.nl>
2019-09-24 19:22:36 +02:00
Robin Appelman 84b9e9f1ae
log which storage id can't be inserted
Signed-off-by: Robin Appelman <robin@icewind.nl>
2019-09-24 13:55:37 +02:00
2 changed files with 10 additions and 2 deletions

View File

@ -81,7 +81,7 @@ class Storage {
if ($row = self::getStorageById($this->storageId)) {
$this->numericId = (int)$row['numeric_id'];
} else {
throw new \RuntimeException('Storage could neither be inserted nor be selected from the database');
throw new \RuntimeException('Storage could neither be inserted nor be selected from the database: ' . $this->storageId);
}
}
}

View File

@ -69,7 +69,15 @@ class StorageGlobal {
*/
public function getStorageInfo($storageId) {
if (!isset($this->cache[$storageId])) {
$this->loadForStorageIds([$storageId]);
$builder = $this->connection->getQueryBuilder();
$query = $builder->select(['id', 'numeric_id', 'available', 'last_checked'])
->from('storages')
->where($builder->expr()->eq('id', $builder->createNamedParameter($storageId)));
$row = $query->execute()->fetch();
if ($row) {
$this->cache[$storageId] = $row;
}
}
return isset($this->cache[$storageId]) ? $this->cache[$storageId] : null;
}