3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2019
37 * This class contains generic upgrade logic which runs regardless of version.
39 class CRM_Upgrade_Incremental_General
{
42 * The recommended PHP version.
44 const RECOMMENDED_PHP_VER
= '7.2';
47 * The previous recommended PHP version.
49 const MIN_RECOMMENDED_PHP_VER
= '7.1';
52 * The minimum PHP version required to install Civi.
54 * @see install/index.php
56 const MIN_INSTALL_PHP_VER
= '7.0';
59 * Compute any messages which should be displayed before upgrade.
61 * @param string $preUpgradeMessage
66 public static function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $latestVer) {
67 $dateFormat = Civi
::Settings()->get('dateformatshortdate');
68 if (version_compare(phpversion(), self
::MIN_RECOMMENDED_PHP_VER
) < 0) {
69 $preUpgradeMessage .= '<p>';
70 $preUpgradeMessage .= ts('You may proceed with the upgrade and CiviCRM %1 will continue working normally, but future releases will require PHP %2 or above. We recommend PHP version %3.', [
72 2 => self
::MIN_RECOMMENDED_PHP_VER
,
73 3 => self
::RECOMMENDED_PHP_VER
,
75 $preUpgradeMessage .= '</p>';
78 // http://issues.civicrm.org/jira/browse/CRM-13572
79 // Depending on how the code was upgraded, some sites may still have copies of old
80 // source files left behind. This is often a forgivable offense, but it's quite
81 // dangerous for CIVI-SA-2013-001.
83 $ofcFile = "$civicrm_root/packages/OpenFlashChart/php-ofc-library/ofc_upload_image.php";
84 if (file_exists($ofcFile)) {
85 if (@unlink
($ofcFile)) {
86 $preUpgradeMessage .= '<br />' . ts('This system included an outdated, insecure script (%1). The file was automatically deleted.', [
91 $preUpgradeMessage .= '<br />' . ts('This system includes an outdated, insecure script (%1). Please delete it.', [
97 if (Civi
::settings()->get('enable_innodb_fts')) {
98 // The FTS indexing feature dynamically manipulates the schema which could
99 // cause conflicts with other layers that manipulate the schema. The
100 // simplest thing is to turn it off and back on.
102 // It may not always be necessary to do this -- but I doubt we're going to test
103 // systematically in future releases. When it is necessary, one could probably
104 // ignore the matter and simply run CRM_Core_InnoDBIndexer::fixSchemaDifferences
105 // after the upgrade. But that's speculative. For now, we'll leave this
106 // advanced feature in the hands of the sysadmin.
107 $preUpgradeMessage .= '<br />' . ts('This database uses InnoDB Full Text Search for optimized searching. The upgrade procedure has not been tested with this feature. You should disable (and later re-enable) the feature by navigating to "Administer => Customize Data and Screens => Search Preferences".');
110 $ftAclSetting = Civi
::settings()->get('acl_financial_type');
111 $financialAclExtension = civicrm_api3('extension', 'get', ['key' => 'biz.jmaconsulting.financialaclreport']);
112 if ($ftAclSetting && (($financialAclExtension['count'] == 1 && $financialAclExtension['status'] != 'Installed') ||
$financialAclExtension['count'] !== 1)) {
113 $preUpgradeMessage .= '<br />' . ts('CiviCRM will in the future require the extension %1 for CiviCRM Reports to work correctly with the Financial Type ACLs. The extension can be downloaded <a href="%2">here</a>', [
114 1 => 'biz.jmaconsulting.financialaclreport',
115 2 => 'https://github.com/JMAConsulting/biz.jmaconsulting.financialaclreport',
121 * Perform any message template updates. 5.0+.
125 public static function updateMessageTemplate(&$message, $version) {
126 if (version_compare($version, 5.0, '<')) {
129 $messageObj = new CRM_Upgrade_Incremental_MessageTemplates($version);
130 $messages = $messageObj->getUpgradeMessages();
131 if (empty($messages)) {
134 $messagesHtml = array_map(function($k, $v) {
135 return sprintf("<li><em>%s</em> - %s</li>", htmlentities($k), htmlentities($v));
136 }, array_keys($messages), $messages);
138 $message .= '<br />' . ts("The default copies of the message templates listed below will be updated to handle new features or correct a problem. Your installation has customized versions of these message templates, and you will need to apply the updates manually after running this upgrade. <a href='%1' style='color:white; text-decoration:underline; font-weight:bold;' target='_blank'>Click here</a> for detailed instructions. %2", [
139 1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Message+Templates#MessageTemplates-UpgradesandCustomizedSystemWorkflowTemplates',
140 2 => '<ul>' . implode('', $messagesHtml) . '</ul>',
143 $messageObj->updateTemplates();
151 public static function checkMessageTemplate(&$message, $latestVer, $currentVer) {
152 if (version_compare($currentVer, 5.0, '>')) {
155 $sql = "SELECT orig.workflow_id as workflow_id,
156 orig.msg_title as title
157 FROM civicrm_msg_template diverted JOIN civicrm_msg_template orig ON (
158 diverted.workflow_id = orig.workflow_id AND
159 orig.is_reserved = 1 AND (
160 diverted.msg_subject != orig.msg_subject OR
161 diverted.msg_text != orig.msg_text OR
162 diverted.msg_html != orig.msg_html
166 $dao = CRM_Core_DAO
::executeQuery($sql);
167 while ($dao->fetch()) {
168 $workflows[$dao->workflow_id
] = $dao->title
;
171 if (empty($workflows)) {
176 $pathName = dirname(dirname(__FILE__
));
178 foreach ($workflows as $workflow => $title) {
179 $name = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionValue',
185 // check if file exists locally
186 $textFileName = implode(DIRECTORY_SEPARATOR
,
189 "{$latestVer}.msg_template",
195 $htmlFileName = implode(DIRECTORY_SEPARATOR
,
198 "{$latestVer}.msg_template",
204 if (file_exists($textFileName) ||
205 file_exists($htmlFileName)
208 $html .= "<li>{$title}</li>";
213 $html = "<ul>" . $html . "<ul>";
215 $message .= '<br />' . ts("The default copies of the message templates listed below will be updated to handle new features or correct a problem. Your installation has customized versions of these message templates, and you will need to apply the updates manually after running this upgrade. <a href='%1' style='color:white; text-decoration:underline; font-weight:bold;' target='_blank'>Click here</a> for detailed instructions. %2", [
216 1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Message+Templates#MessageTemplates-UpgradesandCustomizedSystemWorkflowTemplates',