mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-02 03:16:11 +01:00
Fix for processing exiting after removing package so events are not fired on missing plugins
This commit is contained in:
@@ -958,12 +958,11 @@ class AdminController extends AdminBaseController
|
||||
$type = isset($data['type']) ? $data['type'] : '';
|
||||
|
||||
if (!$this->authorizeTask('uninstall ' . $type, ['admin.' . $type, 'admin.super'])) {
|
||||
$this->admin->json_response = [
|
||||
$json_response = [
|
||||
'status' => 'error',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK')
|
||||
];
|
||||
|
||||
return false;
|
||||
echo json_encode($json_response);exit;
|
||||
}
|
||||
|
||||
//check if there are packages that have this as a dependency. Abort and show which ones
|
||||
@@ -977,31 +976,31 @@ class AdminController extends AdminBaseController
|
||||
$dependent_packages) . "</cyan> depends on this package. Please remove it first.";
|
||||
}
|
||||
|
||||
$this->admin->json_response = ['status' => 'error', 'message' => $message];
|
||||
|
||||
return false;
|
||||
$json_response = ['status' => 'error', 'message' => $message];
|
||||
echo json_encode($json_response);exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$dependencies = $this->admin->dependenciesThatCanBeRemovedWhenRemoving($package);
|
||||
$result = Gpm::uninstall($package, []);
|
||||
} catch (\Exception $e) {
|
||||
$this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
||||
|
||||
return false;
|
||||
$json_response = ['status' => 'error', 'message' => $e->getMessage()];
|
||||
echo json_encode($json_response);exit;
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
$this->admin->json_response = [
|
||||
$json_response = [
|
||||
'status' => 'success',
|
||||
'dependencies' => $dependencies,
|
||||
'message' => $this->admin->translate(is_string($result) ? $result : 'PLUGIN_ADMIN.UNINSTALL_SUCCESSFUL')
|
||||
];
|
||||
echo json_encode($json_response);exit;
|
||||
} else {
|
||||
$this->admin->json_response = [
|
||||
$json_response = [
|
||||
'status' => 'error',
|
||||
'message' => $this->admin->translate('PLUGIN_ADMIN.UNINSTALL_FAILED')
|
||||
];
|
||||
echo json_encode($json_response);exit;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user