- foreach ($compatInfo as $key => $ext) {
- if (!empty($ext['obsolete']) && $manager->getStatus($key) == $manager::STATUS_INSTALLED) {
- $disabled[$key] = sprintf("<li>%s</li>", ts('The extension %1 is now obsolete and has been disabled.', [1 => $key]));
+ foreach ($manager->getStatuses() as $key => $status) {
+ $obsolete = $manager->isIncompatible($key);
+ if ($obsolete) {
+ if (!empty($obsolete['disable']) && in_array($status, [$manager::STATUS_INSTALLED, $manager::STATUS_INSTALLED_MISSING])) {
+ try {
+ $manager->disable($key);
+ // Update the status for the sake of uninstall below.
+ $status = $status == $manager::STATUS_INSTALLED ? $manager::STATUS_DISABLED : $manager::STATUS_DISABLED_MISSING;
+ // This message is intentionally overwritten by uninstall below as it would be redundant
+ $messages[$key] = ts('The extension %1 is now obsolete and has been disabled.', [1 => $key]);
+ }
+ catch (CRM_Extension_Exception $e) {
+ $messages[] = ts('The obsolete extension %1 could not be removed due to an error. It is recommended to remove this extension manually.', [1 => $key]);
+ }
+ }
+ if (!empty($obsolete['uninstall']) && in_array($status, [$manager::STATUS_DISABLED, $manager::STATUS_DISABLED_MISSING])) {
+ try {
+ $manager->uninstall($key);
+ $messages[$key] = ts('The extension %1 is now obsolete and has been uninstalled.', [1 => $key]);
+ if ($status == $manager::STATUS_DISABLED) {
+ $messages[$key] .= ' ' . ts('You can remove it from your extensions directory.');
+ }
+ }
+ catch (CRM_Extension_Exception $e) {
+ $messages[] = ts('The obsolete extension %1 could not be removed due to an error. It is recommended to remove this extension manually.', [1 => $key]);
+ }
+ }
+ if (!empty($obsolete['force-uninstall'])) {
+ CRM_Core_DAO::executeQuery('UPDATE civicrm_extension SET is_active = 0 WHERE full_name = %1', [
+ 1 => [$key, 'String'],
+ ]);
+ }