+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
+ | Copyright CiviCRM LLC (c) 2004-2020 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC (c) 2004-2020
* $Id$
*
*/
/**
* Minimum php version required to run (equal to or lower than the minimum install version)
*
- * Even though 5.6 is no longer supported, this value is left here for a while
- * so as not to block stragglers from upgrading.
+ * As of Civi 5.16, using PHP 5.x will lead to a hard crash during bootstrap.
*/
- const MINIMUM_PHP_VERSION = '5.6';
+ const MINIMUM_PHP_VERSION = '7.0.0';
/**
* @var \CRM_Core_Config
}
/**
- * Disable any extensions not compatible with this new version.
+ * Disable/uninstall any extensions not compatible with this new version.
*
* @param \CRM_Queue_TaskContext $ctx
* @param string $postUpgradeMessageFile
* @return bool
*/
public static function disableOldExtensions(CRM_Queue_TaskContext $ctx, $postUpgradeMessageFile) {
- $compatInfo = CRM_Extension_System::getCompatibilityInfo();
- $disabled = [];
+ $messages = [];
$manager = CRM_Extension_System::singleton()->getManager();
- 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'],
+ ]);
+ }
}
}
- if ($disabled) {
- $manager->disable(array_keys($disabled));
+ if ($messages) {
file_put_contents($postUpgradeMessageFile,
- '<br/><br/><ul>' . implode("\n", $disabled) . '</ul>',
+ '<br/><br/><ul><li>' . implode("</li>\n<li>", $messages) . '</li></ul>',
FILE_APPEND
);
}