remove never-used option value
[civicrm-core.git] / CRM / Upgrade / Incremental / php / FiveTwentySeven.php
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 /**
13 * Upgrade logic for FiveTwentySeven */
14 class CRM_Upgrade_Incremental_php_FiveTwentySeven extends CRM_Upgrade_Incremental_Base {
15
16 /**
17 * Compute any messages which should be displayed beforeupgrade.
18 *
19 * Note: This function is called iteratively for each upcoming
20 * revision to the database.
21 *
22 * @param string $preUpgradeMessage
23 * @param string $rev
24 * a version number, e.g. '4.4.alpha1', '4.4.beta3', '4.4.0'.
25 * @param null $currentVer
26 */
27 public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
28 // Example: Generate a pre-upgrade message.
29 // if ($rev == '5.12.34') {
30 // $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>';
31 // }
32 if ($rev == '5.27.alpha1') {
33 $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>';
34 }
35 }
36
37 /**
38 * Compute any messages which should be displayed after upgrade.
39 *
40 * @param string $postUpgradeMessage
41 * alterable.
42 * @param string $rev
43 * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
44 */
45 public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
46 // Example: Generate a post-upgrade message.
47 // if ($rev == '5.12.34') {
48 // $postUpgradeMessage .= '<br /><br />' . ts("By default, CiviCRM now disables the ability to import directly from SQL. To use this feature, you must explicitly grant permission 'import SQL datasource'.");
49 // }
50 }
51
52 /*
53 * Important! All upgrade functions MUST add a 'runSql' task.
54 * Uncomment and use the following template for a new upgrade version
55 * (change the x in the function name):
56 */
57
58 /**
59 * Upgrade function.
60 *
61 * @param string $rev
62 */
63 public function upgrade_5_27_alpha1($rev) {
64 // Add column before running sql which populates the column's values
65 $this->addTask('Add serialize column to civicrm_custom_field', 'addColumn',
66 'civicrm_custom_field', 'serialize', "int unsigned DEFAULT NULL COMMENT 'Serialization method - a non-null value indicates a multi-valued field.'"
67 );
68 $this->addTask('Make the label field required on price field value', 'priceFieldValueLabelRequired');
69 $this->addTask('Make the name field required on civicrm_membership_type', 'nameMembershipTypeRequired');
70 $this->addTask('Rebuild Multilingal Schema', 'rebuildMultilingalSchema', '5.27.alpha1');
71 $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
72 }
73
74 public function priceFieldValueLabelRequired($ctx) {
75 $locales = CRM_Core_I18n::getMultilingual();
76 if ($locales) {
77 foreach ($locales as $locale) {
78 CRM_Core_DAO::executeQuery("UPDATE civicrm_price_field_value SET label_{$locale} = '' WHERE label_{$locale} IS NULL", [], TRUE, NULL, FALSE, FALSE);
79 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);
80 }
81 }
82 else {
83 CRM_Core_DAO::executeQuery("UPDATE civicrm_price_field_value SET label = '' WHERE label IS NULL");
84 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);
85 }
86 return TRUE;
87 }
88
89 public function nameMembershipTypeRequired($ctx) {
90 $locales = CRM_Core_I18n::getMultilingual();
91 if ($locales) {
92 foreach ($locales as $locale) {
93 CRM_Core_DAO::executeQuery("UPDATE civicrm_membership_type SET name_{$locale} = '' WHERE name_{$locale} IS NULL", [], TRUE, NULL, FALSE, FALSE);
94 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);
95 }
96 }
97 else {
98 CRM_Core_DAO::executeQuery("UPDATE civicrm_membership_type SET name = '' WHERE name IS NULL");
99 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);
100 }
101 return TRUE;
102 }
103
104 }