Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | * $Id$ |
17 | * | |
18 | */ | |
19 | ||
20 | /** | |
49368097 | 21 | * This class contains generic upgrade logic which runs regardless of version. |
6a488035 | 22 | */ |
49368097 | 23 | class CRM_Upgrade_Incremental_General { |
d0c1e96f TO |
24 | |
25 | /** | |
26 | * The recommended PHP version. | |
f955c30c AH |
27 | * |
28 | * The point release will be dropped in recommendations unless it's .1 or | |
29 | * higher. | |
d0c1e96f | 30 | */ |
f955c30c | 31 | const RECOMMENDED_PHP_VER = '7.3.0'; |
d89ec50a SL |
32 | |
33 | /** | |
f955c30c AH |
34 | * The minimum recommended PHP version. |
35 | * | |
36 | * A site running an earlier version will be told to upgrade. | |
d89ec50a | 37 | */ |
f955c30c | 38 | const MIN_RECOMMENDED_PHP_VER = '7.2.0'; |
d0c1e96f TO |
39 | |
40 | /** | |
41 | * The minimum PHP version required to install Civi. | |
42 | * | |
43 | * @see install/index.php | |
44 | */ | |
f955c30c | 45 | const MIN_INSTALL_PHP_VER = '7.1.0'; |
d0c1e96f | 46 | |
965596b4 SL |
47 | /** |
48 | * The minimum recommended MySQL/MariaDB version. | |
49 | * | |
50 | * A site running an earlier version will be told to upgrade. | |
51 | */ | |
52 | const MIN_RECOMMENDED_MYSQL_VER = '5.7'; | |
53 | ||
54 | /** | |
55 | * The minimum MySQL/MariaDB version required to install Civi. | |
56 | * | |
57 | * @see install/index.php | |
58 | */ | |
59 | const MIN_INSTALL_MYSQL_VER = '5.5'; | |
60 | ||
6a488035 | 61 | /** |
fe482240 | 62 | * Compute any messages which should be displayed before upgrade. |
6a488035 | 63 | * |
5a4f6742 CW |
64 | * @param string $preUpgradeMessage |
65 | * alterable. | |
77b97be7 EM |
66 | * @param $currentVer |
67 | * @param $latestVer | |
6a488035 | 68 | */ |
00be9182 | 69 | public static function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $latestVer) { |
d89ec50a | 70 | $dateFormat = Civi::Settings()->get('dateformatshortdate'); |
0632a523 | 71 | if (version_compare(phpversion(), self::MIN_RECOMMENDED_PHP_VER) < 0) { |
d89ec50a | 72 | $preUpgradeMessage .= '<p>'; |
be2fb01f | 73 | $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.', [ |
3655bea4 SL |
74 | 1 => $latestVer, |
75 | 2 => self::MIN_RECOMMENDED_PHP_VER, | |
f955c30c | 76 | 3 => preg_replace(';^(\d+\.\d+(?:\.[1-9]\d*)?).*$;', '\1', self::RECOMMENDED_PHP_VER), |
be2fb01f | 77 | ]); |
d89ec50a | 78 | $preUpgradeMessage .= '</p>'; |
0632a523 CW |
79 | } |
80 | ||
7abafcbc TO |
81 | // http://issues.civicrm.org/jira/browse/CRM-13572 |
82 | // Depending on how the code was upgraded, some sites may still have copies of old | |
83 | // source files left behind. This is often a forgivable offense, but it's quite | |
84 | // dangerous for CIVI-SA-2013-001. | |
fde21984 TO |
85 | global $civicrm_root; |
86 | $ofcFile = "$civicrm_root/packages/OpenFlashChart/php-ofc-library/ofc_upload_image.php"; | |
87 | if (file_exists($ofcFile)) { | |
7abafcbc | 88 | if (@unlink($ofcFile)) { |
be2fb01f | 89 | $preUpgradeMessage .= '<br />' . ts('This system included an outdated, insecure script (%1). The file was automatically deleted.', [ |
3655bea4 SL |
90 | 1 => $ofcFile, |
91 | ]); | |
0db6c3e1 TO |
92 | } |
93 | else { | |
be2fb01f | 94 | $preUpgradeMessage .= '<br />' . ts('This system includes an outdated, insecure script (%1). Please delete it.', [ |
3655bea4 SL |
95 | 1 => $ofcFile, |
96 | ]); | |
7abafcbc | 97 | } |
fde21984 | 98 | } |
f3103b87 | 99 | |
84fb7424 | 100 | if (Civi::settings()->get('enable_innodb_fts')) { |
f3103b87 TO |
101 | // The FTS indexing feature dynamically manipulates the schema which could |
102 | // cause conflicts with other layers that manipulate the schema. The | |
103 | // simplest thing is to turn it off and back on. | |
104 | ||
105 | // It may not always be necessary to do this -- but I doubt we're going to test | |
106 | // systematically in future releases. When it is necessary, one could probably | |
107 | // ignore the matter and simply run CRM_Core_InnoDBIndexer::fixSchemaDifferences | |
108 | // after the upgrade. But that's speculative. For now, we'll leave this | |
109 | // advanced feature in the hands of the sysadmin. | |
ee705313 | 110 | $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".'); |
f3103b87 | 111 | } |
5c3f5819 SL |
112 | |
113 | $ftAclSetting = Civi::settings()->get('acl_financial_type'); | |
be2fb01f | 114 | $financialAclExtension = civicrm_api3('extension', 'get', ['key' => 'biz.jmaconsulting.financialaclreport']); |
5c3f5819 | 115 | if ($ftAclSetting && (($financialAclExtension['count'] == 1 && $financialAclExtension['status'] != 'Installed') || $financialAclExtension['count'] !== 1)) { |
be2fb01f | 116 | $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>', [ |
5c3f5819 SL |
117 | 1 => 'biz.jmaconsulting.financialaclreport', |
118 | 2 => 'https://github.com/JMAConsulting/biz.jmaconsulting.financialaclreport', | |
be2fb01f | 119 | ]); |
5c3f5819 | 120 | } |
6a488035 TO |
121 | } |
122 | ||
fe83c251 | 123 | /** |
124 | * Perform any message template updates. 5.0+. | |
125 | * @param $message | |
126 | * @param $version | |
127 | */ | |
128 | public static function updateMessageTemplate(&$message, $version) { | |
129 | if (version_compare($version, 5.0, '<')) { | |
130 | return; | |
131 | } | |
132 | $messageObj = new CRM_Upgrade_Incremental_MessageTemplates($version); | |
133 | $messages = $messageObj->getUpgradeMessages(); | |
134 | if (empty($messages)) { | |
135 | return; | |
136 | } | |
7d39079e TO |
137 | $messagesHtml = array_map(function($k, $v) { |
138 | return sprintf("<li><em>%s</em> - %s</li>", htmlentities($k), htmlentities($v)); | |
139 | }, array_keys($messages), $messages); | |
140 | ||
be2fb01f | 141 | $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", [ |
6a0dab94 | 142 | 1 => 'https://docs.civicrm.org/user/en/latest/email/message-templates/#modifying-system-workflow-message-templates', |
3655bea4 SL |
143 | 2 => '<ul>' . implode('', $messagesHtml) . '</ul>', |
144 | ]); | |
fe83c251 | 145 | |
146 | $messageObj->updateTemplates(); | |
147 | } | |
148 | ||
624e56fa | 149 | /** |
624e56fa EM |
150 | * @param $message |
151 | * @param $latestVer | |
152 | * @param $currentVer | |
153 | */ | |
49368097 | 154 | public static function checkMessageTemplate(&$message, $latestVer, $currentVer) { |
fe83c251 | 155 | if (version_compare($currentVer, 5.0, '>')) { |
156 | return; | |
157 | } | |
6a488035 TO |
158 | $sql = "SELECT orig.workflow_id as workflow_id, |
159 | orig.msg_title as title | |
160 | FROM civicrm_msg_template diverted JOIN civicrm_msg_template orig ON ( | |
161 | diverted.workflow_id = orig.workflow_id AND | |
162 | orig.is_reserved = 1 AND ( | |
163 | diverted.msg_subject != orig.msg_subject OR | |
164 | diverted.msg_text != orig.msg_text OR | |
165 | diverted.msg_html != orig.msg_html | |
166 | ) | |
167 | )"; | |
168 | ||
49368097 | 169 | $dao = CRM_Core_DAO::executeQuery($sql); |
6a488035 TO |
170 | while ($dao->fetch()) { |
171 | $workflows[$dao->workflow_id] = $dao->title; | |
172 | } | |
173 | ||
174 | if (empty($workflows)) { | |
175 | return; | |
176 | } | |
177 | ||
353ffa53 | 178 | $html = NULL; |
6a488035 | 179 | $pathName = dirname(dirname(__FILE__)); |
353ffa53 | 180 | $flag = FALSE; |
6a488035 TO |
181 | foreach ($workflows as $workflow => $title) { |
182 | $name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', | |
183 | $workflow, | |
184 | 'name', | |
185 | 'id' | |
186 | ); | |
187 | ||
188 | // check if file exists locally | |
189 | $textFileName = implode(DIRECTORY_SEPARATOR, | |
be2fb01f | 190 | [ |
6a488035 TO |
191 | $pathName, |
192 | "{$latestVer}.msg_template", | |
193 | 'message_templates', | |
194 | "{$name}_text.tpl", | |
be2fb01f | 195 | ] |
6a488035 TO |
196 | ); |
197 | ||
198 | $htmlFileName = implode(DIRECTORY_SEPARATOR, | |
be2fb01f | 199 | [ |
6a488035 TO |
200 | $pathName, |
201 | "{$latestVer}.msg_template", | |
202 | 'message_templates', | |
203 | "{$name}_html.tpl", | |
be2fb01f | 204 | ] |
6a488035 TO |
205 | ); |
206 | ||
207 | if (file_exists($textFileName) || | |
208 | file_exists($htmlFileName) | |
209 | ) { | |
210 | $flag = TRUE; | |
211 | $html .= "<li>{$title}</li>"; | |
212 | } | |
213 | } | |
214 | ||
215 | if ($flag == TRUE) { | |
216 | $html = "<ul>" . $html . "<ul>"; | |
217 | ||
be2fb01f | 218 | $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", [ |
6a0dab94 | 219 | 1 => 'https://docs.civicrm.org/user/en/latest/email/message-templates/#modifying-system-workflow-message-templates', |
3655bea4 SL |
220 | 2 => $html, |
221 | ]); | |
6a488035 TO |
222 | } |
223 | } | |
224 | ||
6a488035 | 225 | } |