be more accurate to enable direct action on disabled module

This commit is contained in:
Jean-Christian Paul Denis 2023-05-14 20:53:32 +02:00
parent 239820a510
commit ec3c438fee
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951

View File

@ -81,15 +81,23 @@ class Backend extends dcNsProcess
*/ */
protected static function moduleBeforeDelete(dcModuleDefine $define): void protected static function moduleBeforeDelete(dcModuleDefine $define): void
{ {
if (dcCore::app()->blog?->settings->get('system')->get('no_uninstall_direct') if (dcCore::app()->blog?->settings->get('system')->get('no_uninstall_direct')) {
|| $define->get('state') != dcModuleDefine::STATE_ENABLED
) {
return; return;
} }
try { try {
$uninstaller = Uninstaller::instance()->loadModules([$define]); $uninstaller = Uninstaller::instance()->loadModules([$define]);
// Do not perform action on disabled module if a duplicate exists.
if ($define->get('state') != dcModuleDefine::STATE_ENABLED) {
if (!in_array($define->get('type'), ['plugin', 'theme'])
|| $define->get('type') == 'plugin' && 1 < count(dcCore::app()->plugins->getDefines(['id' => $define->getId()]))
|| $define->get('type') == 'theme' && 1 < count(dcCore::app()->themes->getDefines(['id' => $define->getId()]))
) {
return;
}
}
$done = []; $done = [];
foreach ($uninstaller->getDirectActions($define->getId()) as $cleaner => $stack) { foreach ($uninstaller->getDirectActions($define->getId()) as $cleaner => $stack) {
foreach ($stack as $action) { foreach ($stack as $action) {