Merge pull request #23360 from eileenmcnaughton/import_var
[civicrm-core.git] / CRM / Upgrade / Incremental / php / FiveTwentySeven.php
CommitLineData
7db0b5fd
C
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 |
9 +--------------------------------------------------------------------+
10 */
11
12/**
6317d291
CW
13 * Upgrade logic for FiveTwentySeven
14 */
7db0b5fd
C
15class CRM_Upgrade_Incremental_php_FiveTwentySeven extends CRM_Upgrade_Incremental_Base {
16
17 /**
18 * Compute any messages which should be displayed beforeupgrade.
19 *
20 * Note: This function is called iteratively for each upcoming
21 * revision to the database.
22 *
23 * @param string $preUpgradeMessage
24 * @param string $rev
25 * a version number, e.g. '4.4.alpha1', '4.4.beta3', '4.4.0'.
26 * @param null $currentVer
27 */
28 public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
29 // Example: Generate a pre-upgrade message.
30 // if ($rev == '5.12.34') {
31 // $preUpgradeMessage .= '<p>' . ts('A new permission, "%1", has been added. This permission is now used to control access to the Manage Tags screen.', array(1 => ts('manage tags'))) . '</p>';
32 // }
70bbc67e 33 if ($rev == '5.27.alpha1') {
1c0b0693 34 $preUpgradeMessage .= '<p>' . ts('Starting with version 5.28.0, CiviCRM will require the PHP Internationalization extension (PHP-Intl). In preparation for this, the system check will show a warning beginning in 5.27.0 if your site lacks this extension.') . '</p>';
70bbc67e 35 }
7db0b5fd
C
36 }
37
2bcfa9ee
CW
38 /**
39 * Upgrade function.
40 *
41 * @param string $rev
42 */
43 public function upgrade_5_27_alpha1($rev) {
44 // Add column before running sql which populates the column's values
45 $this->addTask('Add serialize column to civicrm_custom_field', 'addColumn',
46 'civicrm_custom_field', 'serialize', "int unsigned DEFAULT NULL COMMENT 'Serialization method - a non-null value indicates a multi-valued field.'"
47 );
9d810a94
SL
48 $this->addTask('Make the label field required on price field value', 'priceFieldValueLabelRequired');
49 $this->addTask('Make the name field required on civicrm_membership_type', 'nameMembershipTypeRequired');
50 $this->addTask('Rebuild Multilingal Schema', 'rebuildMultilingalSchema', '5.27.alpha1');
2bcfa9ee
CW
51 $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
52 }
7db0b5fd 53
adcd5156 54 public static function priceFieldValueLabelRequired($ctx) {
394d18d3
CW
55 $locales = CRM_Core_I18n::getMultilingual();
56 if ($locales) {
9d810a94 57 foreach ($locales as $locale) {
870ea1a7 58 CRM_Core_DAO::executeQuery("UPDATE civicrm_price_field_value SET label_{$locale} = '' WHERE label_{$locale} IS NULL", [], TRUE, NULL, FALSE, FALSE);
9d810a94
SL
59 CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_price_field_value CHANGE `label_{$locale}` `label_{$locale}` varchar(255) NOT NULL COMMENT 'Price field option label'", [], TRUE, NULL, FALSE, FALSE);
60 }
61 }
62 else {
870ea1a7 63 CRM_Core_DAO::executeQuery("UPDATE civicrm_price_field_value SET label = '' WHERE label IS NULL");
9d810a94
SL
64 CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_price_field_value CHANGE `label` `label` varchar(255) NOT NULL COMMENT 'Price field option label'", [], TRUE, NULL, FALSE, FALSE);
65 }
66 return TRUE;
67 }
68
adcd5156 69 public static function nameMembershipTypeRequired($ctx) {
394d18d3
CW
70 $locales = CRM_Core_I18n::getMultilingual();
71 if ($locales) {
9d810a94 72 foreach ($locales as $locale) {
870ea1a7 73 CRM_Core_DAO::executeQuery("UPDATE civicrm_membership_type SET name_{$locale} = '' WHERE name_{$locale} IS NULL", [], TRUE, NULL, FALSE, FALSE);
9d810a94
SL
74 CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_membership_type CHANGE `name_{$locale}` `name_{$locale}` varchar(128) NOT NULL COMMENT 'Name of Membership Type'", [], TRUE, NULL, FALSE, FALSE);
75 }
76 }
77 else {
870ea1a7 78 CRM_Core_DAO::executeQuery("UPDATE civicrm_membership_type SET name = '' WHERE name IS NULL");
9d810a94
SL
79 CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_membership_type CHANGE `name` `name` varchar(128) NOT NULL COMMENT 'Name of Membership Type'", [], TRUE, NULL, FALSE, FALSE);
80 }
81 return TRUE;
82 }
83
7db0b5fd 84}