forked from Alex/Pterodactyl-Panel
transfers: fix allocation array merging logic (#3551)
This commit is contained in:
parent
b94d69bbab
commit
b4cae916ac
@ -146,17 +146,14 @@ class ServerTransferController extends Controller
|
|||||||
*
|
*
|
||||||
* @throws \Throwable
|
* @throws \Throwable
|
||||||
*/
|
*/
|
||||||
public function success(string $uuid)
|
public function success(string $uuid): JsonResponse
|
||||||
{
|
{
|
||||||
$server = $this->repository->getByUuid($uuid);
|
$server = $this->repository->getByUuid($uuid);
|
||||||
$transfer = $server->transfer;
|
$transfer = $server->transfer;
|
||||||
|
|
||||||
/** @var \Pterodactyl\Models\Server $server */
|
/** @var \Pterodactyl\Models\Server $server */
|
||||||
$server = $this->connection->transaction(function () use ($server, $transfer) {
|
$server = $this->connection->transaction(function () use ($server, $transfer) {
|
||||||
$allocations = [$transfer->old_allocation];
|
$allocations = array_merge([$transfer->old_allocation], $transfer->old_additional_allocations);
|
||||||
if (!empty($transfer->old_additional_allocations)) {
|
|
||||||
array_push($allocations, $transfer->old_additional_allocations);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the old allocations for the server and re-assign the server to the new
|
// Remove the old allocations for the server and re-assign the server to the new
|
||||||
// primary allocation and node.
|
// primary allocation and node.
|
||||||
@ -173,7 +170,7 @@ class ServerTransferController extends Controller
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Delete the server from the old node making sure to point it to the old node so
|
// Delete the server from the old node making sure to point it to the old node so
|
||||||
// that we do not delete it from the new node the server was transfered to.
|
// that we do not delete it from the new node the server was transferred to.
|
||||||
try {
|
try {
|
||||||
$this->daemonServerRepository
|
$this->daemonServerRepository
|
||||||
->setServer($server)
|
->setServer($server)
|
||||||
@ -199,11 +196,7 @@ class ServerTransferController extends Controller
|
|||||||
$this->connection->transaction(function () use (&$transfer) {
|
$this->connection->transaction(function () use (&$transfer) {
|
||||||
$transfer->forceFill(['successful' => false])->saveOrFail();
|
$transfer->forceFill(['successful' => false])->saveOrFail();
|
||||||
|
|
||||||
$allocations = [$transfer->new_allocation];
|
$allocations = array_merge([$transfer->new_allocation], $transfer->new_additional_allocations);
|
||||||
if (!empty($transfer->new_additional_allocations)) {
|
|
||||||
array_push($allocations, $transfer->new_additional_allocations);
|
|
||||||
}
|
|
||||||
|
|
||||||
Allocation::query()->whereIn('id', $allocations)->update(['server_id' => null]);
|
Allocation::query()->whereIn('id', $allocations)->update(['server_id' => null]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user