Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
0f03f337 | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
0f03f337 | 31 | * @copyright CiviCRM LLC (c) 2004-2017 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
49368097 | 37 | * This class contains generic upgrade logic which runs regardless of version. |
6a488035 | 38 | */ |
49368097 | 39 | class CRM_Upgrade_Incremental_General { |
d0c1e96f TO |
40 | |
41 | /** | |
42 | * The recommended PHP version. | |
43 | */ | |
d89ec50a SL |
44 | const MIN_RECOMMENDED_PHP_VER = '5.6'; |
45 | ||
46 | /** | |
47 | * The previous recommended PHP version. | |
48 | */ | |
49 | const PREVIOUS_MIN_RECOMMENDED_PHP_VER = '5.5'; | |
d0c1e96f TO |
50 | |
51 | /** | |
52 | * The minimum PHP version required to install Civi. | |
53 | * | |
54 | * @see install/index.php | |
55 | */ | |
56 | const MIN_INSTALL_PHP_VER = '5.3.4'; | |
57 | ||
58 | /** | |
59 | * The minimum PHP version required to avoid known | |
60 | * limits or defects. | |
61 | */ | |
62 | const MIN_DEFECT_PHP_VER = '5.3.23'; | |
63 | ||
6a488035 | 64 | /** |
fe482240 | 65 | * Compute any messages which should be displayed before upgrade. |
6a488035 | 66 | * |
5a4f6742 CW |
67 | * @param string $preUpgradeMessage |
68 | * alterable. | |
77b97be7 EM |
69 | * @param $currentVer |
70 | * @param $latestVer | |
6a488035 | 71 | */ |
00be9182 | 72 | public static function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $latestVer) { |
d89ec50a | 73 | $dateFormat = Civi::Settings()->get('dateformatshortdate'); |
0632a523 | 74 | if (version_compare(phpversion(), self::MIN_RECOMMENDED_PHP_VER) < 0) { |
d89ec50a SL |
75 | $preUpgradeMessage .= '<p>'; |
76 | // CRM-20941 PHP 5.3 end date of End of 2017, PHP 5.4 End date End of Feb 2018 Recommend anyone on PHP 5.5 to move up to 5.6 or later e.g. 7.0 | |
77 | if (version_compare(phpversion(), self::PREVIOUS_MIN_RECOMMENDED_PHP_VER) >= 0) { | |
2179c94c | 78 | $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 you use the most recent php version you can.', array( |
c1d838e1 | 79 | 1 => $latestVer, |
d89ec50a SL |
80 | 2 => self::MIN_RECOMMENDED_PHP_VER, |
81 | )); | |
82 | } | |
83 | elseif (version_compare(phpversion(), 5.5) < 0) { | |
84 | $date = CRM_Utils_Date::customFormat('2018-02-28', $dateFormat); | |
85 | if (version_compare(phpversion(), 5.4) < 0) { | |
86 | $date = CRM_Utils_Date::customFormat('2017-12-31', $dateFormat); | |
87 | } | |
2179c94c | 88 | $preUpgradeMessage .= ts('You may proceed with the upgrade and CiviCRM %1 will continue working normally, but PHP %2 will not work in releases published after %3. We recommend you use the most recent php version you can. For more explanation see <a href="%4">the announcement</a>.', array( |
d89ec50a SL |
89 | 1 => $currentVer, |
90 | 2 => phpversion(), | |
91 | 3 => $date, | |
66967a8c | 92 | 4 => 'https://civicrm.org/blog/totten/end-of-zombies-php-53-and-54', |
d89ec50a SL |
93 | )); |
94 | } | |
95 | $preUpgradeMessage .= '</p>'; | |
0632a523 CW |
96 | } |
97 | ||
7abafcbc TO |
98 | // http://issues.civicrm.org/jira/browse/CRM-13572 |
99 | // Depending on how the code was upgraded, some sites may still have copies of old | |
100 | // source files left behind. This is often a forgivable offense, but it's quite | |
101 | // dangerous for CIVI-SA-2013-001. | |
fde21984 TO |
102 | global $civicrm_root; |
103 | $ofcFile = "$civicrm_root/packages/OpenFlashChart/php-ofc-library/ofc_upload_image.php"; | |
104 | if (file_exists($ofcFile)) { | |
7abafcbc TO |
105 | if (@unlink($ofcFile)) { |
106 | $preUpgradeMessage .= '<br />' . ts('This system included an outdated, insecure script (%1). The file was automatically deleted.', array( | |
353ffa53 TO |
107 | 1 => $ofcFile, |
108 | )); | |
0db6c3e1 TO |
109 | } |
110 | else { | |
7abafcbc | 111 | $preUpgradeMessage .= '<br />' . ts('This system includes an outdated, insecure script (%1). Please delete it.', array( |
353ffa53 TO |
112 | 1 => $ofcFile, |
113 | )); | |
7abafcbc | 114 | } |
fde21984 | 115 | } |
f3103b87 | 116 | |
84fb7424 | 117 | if (Civi::settings()->get('enable_innodb_fts')) { |
f3103b87 TO |
118 | // The FTS indexing feature dynamically manipulates the schema which could |
119 | // cause conflicts with other layers that manipulate the schema. The | |
120 | // simplest thing is to turn it off and back on. | |
121 | ||
122 | // It may not always be necessary to do this -- but I doubt we're going to test | |
123 | // systematically in future releases. When it is necessary, one could probably | |
124 | // ignore the matter and simply run CRM_Core_InnoDBIndexer::fixSchemaDifferences | |
125 | // after the upgrade. But that's speculative. For now, we'll leave this | |
126 | // advanced feature in the hands of the sysadmin. | |
127 | $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 => System Settings => Miscellaneous".'); | |
128 | } | |
6a488035 TO |
129 | } |
130 | ||
624e56fa | 131 | /** |
624e56fa EM |
132 | * @param $message |
133 | * @param $latestVer | |
134 | * @param $currentVer | |
135 | */ | |
49368097 | 136 | public static function checkMessageTemplate(&$message, $latestVer, $currentVer) { |
6a488035 TO |
137 | |
138 | $sql = "SELECT orig.workflow_id as workflow_id, | |
139 | orig.msg_title as title | |
140 | FROM civicrm_msg_template diverted JOIN civicrm_msg_template orig ON ( | |
141 | diverted.workflow_id = orig.workflow_id AND | |
142 | orig.is_reserved = 1 AND ( | |
143 | diverted.msg_subject != orig.msg_subject OR | |
144 | diverted.msg_text != orig.msg_text OR | |
145 | diverted.msg_html != orig.msg_html | |
146 | ) | |
147 | )"; | |
148 | ||
49368097 | 149 | $dao = CRM_Core_DAO::executeQuery($sql); |
6a488035 TO |
150 | while ($dao->fetch()) { |
151 | $workflows[$dao->workflow_id] = $dao->title; | |
152 | } | |
153 | ||
154 | if (empty($workflows)) { | |
155 | return; | |
156 | } | |
157 | ||
353ffa53 | 158 | $html = NULL; |
6a488035 | 159 | $pathName = dirname(dirname(__FILE__)); |
353ffa53 | 160 | $flag = FALSE; |
6a488035 TO |
161 | foreach ($workflows as $workflow => $title) { |
162 | $name = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', | |
163 | $workflow, | |
164 | 'name', | |
165 | 'id' | |
166 | ); | |
167 | ||
168 | // check if file exists locally | |
169 | $textFileName = implode(DIRECTORY_SEPARATOR, | |
170 | array( | |
171 | $pathName, | |
172 | "{$latestVer}.msg_template", | |
173 | 'message_templates', | |
174 | "{$name}_text.tpl", | |
175 | ) | |
176 | ); | |
177 | ||
178 | $htmlFileName = implode(DIRECTORY_SEPARATOR, | |
179 | array( | |
180 | $pathName, | |
181 | "{$latestVer}.msg_template", | |
182 | 'message_templates', | |
183 | "{$name}_html.tpl", | |
184 | ) | |
185 | ); | |
186 | ||
187 | if (file_exists($textFileName) || | |
188 | file_exists($htmlFileName) | |
189 | ) { | |
190 | $flag = TRUE; | |
191 | $html .= "<li>{$title}</li>"; | |
192 | } | |
193 | } | |
194 | ||
195 | if ($flag == TRUE) { | |
196 | $html = "<ul>" . $html . "<ul>"; | |
197 | ||
353ffa53 TO |
198 | $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", array( |
199 | 1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Message+Templates#MessageTemplates-UpgradesandCustomizedSystemWorkflowTemplates', | |
408b79bf | 200 | 2 => $html, |
353ffa53 | 201 | )); |
6a488035 TO |
202 | } |
203 | } | |
204 | ||
6a488035 | 205 | } |