Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions lib/DatabaseStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,11 @@ protected function databaseSize(): string {
}
break;
case 'pgsql':
$sql = "SELECT proname
FROM pg_proc
WHERE proname = 'pg_database_size'";
$result = $this->connection->executeQuery($sql);
$row = $result->fetch();
$database = $this->config->getSystemValueString('dbname');
$sql = 'SELECT pg_database_size(:dbname) as size';
$result = $this->connection->executeQuery($sql, ['dbname' => $database]);
$database_size = $result->fetchOne();
$result->closeCursor();
if ($row['proname'] === 'pg_database_size') {
$database = $this->config->getSystemValue('dbname');
if (strpos($database, '.') !== false) {
[$database, ] = explode('.', $database);
}
$sql = "SELECT oid
FROM pg_database
WHERE datname = '$database'";
$result = $this->connection->executeQuery($sql);
$row = $result->fetch();
$result->closeCursor();
$oid = $row['oid'];
$sql = 'SELECT pg_database_size(' . $oid . ') as size';
$result = $this->connection->executeQuery($sql);
$row = $result->fetch();
$result->closeCursor();
$database_size = $row['size'];
}
break;
Comment on lines 99 to 105
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PGSQL databaseSize() branch is the core behavior change to fix #556 (db names containing dots) but there’s no automated test asserting the generated SQL/parameters or that dotted DB names are handled correctly. Adding a focused PHPUnit test for the pgsql path (mocking IConfig + IDBConnection/Result) would help prevent regressions.

Copilot uses AI. Check for mistakes.
case 'oci':
$sql = 'SELECT SUM(bytes) as dbsize
Expand Down
18 changes: 13 additions & 5 deletions lib/ShareStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ protected function countEntries(string $tableName): int {
$query->select($query->func()->count('*', 'num_entries'))
->from($tableName);
$result = $query->executeQuery();
$row = $result->fetch();
$row = $result->fetchOne();
$result->closeCursor();

return (int)$row['num_entries'];
if ($row === false) {
return 0;
}

return (int)$row;
}

/**
Expand All @@ -72,7 +76,7 @@ protected function countEntries(string $tableName): int {
*/
protected function countShares(int $type, bool $noPassword = false): int {
$query = $this->connection->getQueryBuilder();
$query->selectAlias($query->createFunction('COUNT(*)'), 'num_entries')
$query->select($query->func()->count('*', 'num_entries'))
->from('share')
->where($query->expr()->eq('share_type', $query->createNamedParameter($type)));

Expand All @@ -81,9 +85,13 @@ protected function countShares(int $type, bool $noPassword = false): int {
}

$result = $query->executeQuery();
$row = $result->fetch();
$row = $result->fetchOne();
$result->closeCursor();

return (int)$row['num_entries'];
if ($row === false) {
return 0;
}

return (int)$row;
}
}
9 changes: 7 additions & 2 deletions lib/StorageStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,14 @@ protected function countStorages(string $type): int {
$query->andWhere($query->expr()->notLike('id', $query->createNamedParameter('local::%')));
}
$result = $query->executeQuery();
$row = $result->fetch();
$row = $result->fetchOne();
$result->closeCursor();
return (int)$row['num_entries'];

if ($row === false) {
return 0;
}

return (int)$row;
}

public function updateAppDataStorageStats(): void {
Expand Down
Loading