$messages = [];
$manager = CRM_Extension_System::singleton()->getManager();
foreach ($manager->getStatuses() as $key => $status) {
+ $enableReplacement = CRM_Core_DAO::singleValueQuery('SELECT is_active FROM civicrm_extension WHERE full_name = %1', [1 => [$key, 'String']]);
$obsolete = $manager->isIncompatible($key);
if ($obsolete) {
if (!empty($obsolete['disable']) && in_array($status, [$manager::STATUS_INSTALLED, $manager::STATUS_INSTALLED_MISSING])) {
1 => [$key, 'String'],
]);
}
+ if (!empty($obsolete['replacement']) && $enableReplacement) {
+ try {
+ $manager->enable($manager->install($obsolete['replacement']));
+ $messages[] = ts('A replacement extension %1 has been installed as you had the obsolete extension %2 installed', [1 => $obsolete['replacement'], 2 => $key]);
+ }
+ catch (CRM_Extension_Exception $e) {
+ $messages[] = ts('The replacement extension %1 could not be installed due to an error. It is recommended to enable this extension manually.', [1 => $obsolete['replacement']]);
+ }
+ }
}
}
if ($messages) {