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:
parent
2cda14bffb
commit
02ac308042
6 changed files with 74 additions and 59 deletions
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue