be more accurate to enable direct action on disabled module

master
Jean-Christian Paul Denis 2023-05-14 20:53:32 +02:00
parent 239820a510
commit ec3c438fee
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
1 changed files with 11 additions and 3 deletions

View File

@ -81,15 +81,23 @@ class Backend extends dcNsProcess
*/
protected static function moduleBeforeDelete(dcModuleDefine $define): void
{
if (dcCore::app()->blog?->settings->get('system')->get('no_uninstall_direct')
|| $define->get('state') != dcModuleDefine::STATE_ENABLED
) {
if (dcCore::app()->blog?->settings->get('system')->get('no_uninstall_direct')) {
return;
}
try {
$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 = [];
foreach ($uninstaller->getDirectActions($define->getId()) as $cleaner => $stack) {
foreach ($stack as $action) {