Show database name and database connection user in system infos

This commit is contained in:
Jan Böhmer 2023-01-16 00:15:15 +01:00
parent 6eb40c6a41
commit 256926be94
4 changed files with 38 additions and 1 deletions

View file

@ -87,6 +87,8 @@ class ToolsController extends AbstractController
'db_type' => $DBInfoHelper->getDatabaseType() ?? 'Unknown', 'db_type' => $DBInfoHelper->getDatabaseType() ?? 'Unknown',
'db_version' => $DBInfoHelper->getDatabaseVersion() ?? 'Unknown', 'db_version' => $DBInfoHelper->getDatabaseVersion() ?? 'Unknown',
'db_size' => $DBInfoHelper->getDatabaseSize(), 'db_size' => $DBInfoHelper->getDatabaseSize(),
'db_name' => $DBInfoHelper->getDatabaseName() ?? 'Unknown',
'db_user' => $DBInfoHelper->getDatabaseUsername() ?? 'Unknown',
]); ]);
} }

View file

@ -100,5 +100,32 @@ class DBInfoHelper
return null; return null;
} }
/**
* Returns the name of the database.
* @return string|null
*/
public function getDatabaseName(): ?string
{
return $this->connection->getDatabase() ?? null;
}
/**
* Returns the name of the database user.
* @return string|null
*/
public function getDatabaseUsername(): ?string
{
if ($this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform) {
try {
return $this->connection->fetchOne('SELECT USER()');
} catch (\Doctrine\DBAL\Exception $e) {
return null;
}
}
if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
return 'sqlite';
}
}
} }

View file

@ -13,5 +13,13 @@
<td>Database Size</td> <td>Database Size</td>
<td>{{ db_size != null ? db_size | format_bytes : 'Unknown' }}</td> <td>{{ db_size != null ? db_size | format_bytes : 'Unknown' }}</td>
</tr> </tr>
<tr>
<td>Database Name</td>
<td>{{ db_name }}</td>
</tr>
<tr>
<td>Database User</td>
<td>{{ db_user }}</td>
</tr>
</tbody> </tbody>
</table> </table>

View file

@ -14,7 +14,7 @@
<td>{{ helper.boolean_badge(php_opcache_enabled) }}</td> <td>{{ helper.boolean_badge(php_opcache_enabled) }}</td>
</tr> </tr>
<tr> <tr>
<td>Maximum upload sizee (upload_max_filesize / post_max_size)</td> <td>Maximum upload size (upload_max_filesize / post_max_size)</td>
<td>{{ php_upload_max_filesize }} / {{ php_post_max_size }}</td> <td>{{ php_upload_max_filesize }} / {{ php_post_max_size }}</td>
</tr> </tr>
<tr> <tr>