mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-19 23:03:45 +02:00
Fix database host modification not properly showing SQL errors
This is caused by an old bug relating to not rolling back transactions properly causing session data to not be flashed back to the user properly.
This commit is contained in:
@@ -65,28 +65,26 @@ class HostCreationService
|
||||
* @param array $data
|
||||
* @return \Pterodactyl\Models\DatabaseHost
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function handle(array $data): DatabaseHost
|
||||
{
|
||||
$this->connection->beginTransaction();
|
||||
return $this->connection->transaction(function () use ($data) {
|
||||
$host = $this->repository->create([
|
||||
'password' => $this->encrypter->encrypt(array_get($data, 'password')),
|
||||
'name' => array_get($data, 'name'),
|
||||
'host' => array_get($data, 'host'),
|
||||
'port' => array_get($data, 'port'),
|
||||
'username' => array_get($data, 'username'),
|
||||
'max_databases' => null,
|
||||
'node_id' => array_get($data, 'node_id'),
|
||||
]);
|
||||
|
||||
$host = $this->repository->create([
|
||||
'password' => $this->encrypter->encrypt(array_get($data, 'password')),
|
||||
'name' => array_get($data, 'name'),
|
||||
'host' => array_get($data, 'host'),
|
||||
'port' => array_get($data, 'port'),
|
||||
'username' => array_get($data, 'username'),
|
||||
'max_databases' => null,
|
||||
'node_id' => array_get($data, 'node_id'),
|
||||
]);
|
||||
// Confirm access using the provided credentials before saving data.
|
||||
$this->dynamic->set('dynamic', $host);
|
||||
$this->databaseManager->connection('dynamic')->select('SELECT 1 FROM dual');
|
||||
|
||||
// Confirm access using the provided credentials before saving data.
|
||||
$this->dynamic->set('dynamic', $host);
|
||||
$this->databaseManager->connection('dynamic')->select('SELECT 1 FROM dual');
|
||||
$this->connection->commit();
|
||||
|
||||
return $host;
|
||||
return $host;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,10 +71,9 @@ class HostUpdateService
|
||||
*
|
||||
* @param int $hostId
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
* @return \Pterodactyl\Models\DatabaseHost
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function handle(int $hostId, array $data): DatabaseHost
|
||||
{
|
||||
@@ -84,13 +83,12 @@ class HostUpdateService
|
||||
unset($data['password']);
|
||||
}
|
||||
|
||||
$this->connection->beginTransaction();
|
||||
$host = $this->repository->update($hostId, $data);
|
||||
return $this->connection->transaction(function () use ($data, $hostId) {
|
||||
$host = $this->repository->update($hostId, $data);
|
||||
$this->dynamic->set('dynamic', $host);
|
||||
$this->databaseManager->connection('dynamic')->select('SELECT 1 FROM dual');
|
||||
|
||||
$this->dynamic->set('dynamic', $host);
|
||||
$this->databaseManager->connection('dynamic')->select('SELECT 1 FROM dual');
|
||||
$this->connection->commit();
|
||||
|
||||
return $host;
|
||||
return $host;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user