Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore civicrm_action_schedule.limit_to (5.49) #23490

Merged
merged 7 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions CRM/Core/DAO/ActionSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Core/ActionSchedule.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:444acdd7b222ed9f593b0b84aebfb763)
* (GenCodeChecksum:79492485b0099dc4a6a101f3191d64dd)
*/

/**
Expand Down Expand Up @@ -67,7 +67,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
/**
* Is this the recipient criteria limited to OR in addition to?
*
* @var bool|string
* @var bool|string|null
* (SQL type: tinyint)
* Note that values will be retrieved from the database as a string.
*/
Expand Down Expand Up @@ -512,9 +512,7 @@ public static function &fields() {
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => ts('Limit To'),
'description' => ts('Is this the recipient criteria limited to OR in addition to?'),
'required' => TRUE,
'where' => 'civicrm_action_schedule.limit_to',
'default' => '1',
'table_name' => 'civicrm_action_schedule',
'entity' => 'ActionSchedule',
'bao' => 'CRM_Core_BAO_ActionSchedule',
Expand Down
74 changes: 74 additions & 0 deletions CRM/Upgrade/Incremental/php/FiveFortyNine.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,38 @@
*/
class CRM_Upgrade_Incremental_php_FiveFortyNine extends CRM_Upgrade_Incremental_Base {

/**
* When executing 5.49.2 upgrade-step, it decides whether to fix limit-to. Remember that decision.
*
* Note: You cannot _generally_ use object-properties to communicate between functions in this class
* (because they reset in diff AJAX requests).
*
* However, you can _specifically_ communicate between `upgrade_N_N_N()` and `setPostUpgradeMessage()`.
* This is because they are guaranteed to run in the same call (as part of `doIncrementalUpgradeStep()`).
*
* @var bool|null
*/
private $executedLimitToFix;

public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
$willExecuteLimitToFix = (bool) version_compare(CRM_Core_BAO_Domain::version(), '5.49.beta1', '>=');
if ($rev == '5.49.2' && $willExecuteLimitToFix) {
$message = $this->createLimitToMessage();
if ($message) {
$preUpgradeMessage .= "<p>{$message}</p>";
}
}
}

public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
if ($rev == '5.49.2' && $this->executedLimitToFix === TRUE) {
$message = $this->createLimitToMessage();
if ($message) {
$postUpgradeMessage .= "<p><strong>" . ts('WARNING') . "</strong>: {$message}</p>";
}
}
}

public static function findBooleanColumns(): array {
$r = [];
$files = CRM_Utils_File::findFiles(__DIR__ . '/FiveFortyNine', '*.bool.php');
Expand Down Expand Up @@ -60,6 +92,48 @@ public function upgrade_5_49_beta1($rev): void {
}
}

/**
* Upgrade function.
*
* @param string $currentRev
* DB revision (which we are currently applying)
* @param string $startRev
* DB revision (when the upgrade started)
* @param string $finalRev
* DB revision (that we're aiming to reach, in the end)
*/
public function upgrade_5_49_2($currentRev, $startRev, $finalRev) {
if (empty($startRev)) {
throw new \RuntimeException("Error: Was somebody too clever about modifying the upgrader? We're missing a little-known but very-handy parameter!");
}
$this->executedLimitToFix = (bool) version_compare($startRev, '5.49.beta1', '>=');
if ($this->executedLimitToFix) {
$this->addTask('Update "civicrm_action_schedule.limit_to" to re-enable "NULL" values', 'changeBooleanColumnLimitTo');
}
}

public function createLimitToMessage(): ?string {
$suspectRecords = CRM_Core_DAO::singleValueQuery("SELECT GROUP_CONCAT(id SEPARATOR \", #\") FROM civicrm_action_schedule WHERE limit_to=0 AND (recipient_manual IS NOT NULL OR group_id IS NOT NULL)");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice formatted ids :)

if (!empty($suspectRecords)) {
return ts('This site previously executed an early version of 5.49, which may have incorrectly modified some scheduled reminders. After upgrading, review these reminders (<code>%1</code>). <a %2>(Learn more...)</a>', [
1 => '#' . $suspectRecords,
2 => 'target="blank" href="https://civicrm.org/redirect/reminders-5.49"',
]);
}
else {
return NULL;
}
}

/**
* Revert boolean default civicrm_action_schedule.limit_to to be NULL
*/
public static function changeBooleanColumnLimitTo() {
CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_action_schedule` CHANGE `limit_to` `limit_to` tinyint NULL COMMENT 'Is this the recipient criteria limited to OR in addition to?'", [], TRUE, NULL, FALSE, FALSE);
CRM_Core_DAO::executeQuery("UPDATE `civicrm_action_schedule` SET `limit_to` = NULL WHERE `limit_to` = 0 AND `group_id` IS NULL AND recipient_manual IS NULL", [], TRUE, NULL, FALSE, FALSE);
return TRUE;
}

/**
* Converts a boolean table column to be NOT NULL
* @param CRM_Queue_TaskContext $ctx
Expand Down
1 change: 0 additions & 1 deletion CRM/Upgrade/Incremental/php/FiveFortyNine/Core.bool.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
return [
'civicrm_action_schedule' => [
'limit_to' => "DEFAULT 1 COMMENT 'Is this the recipient criteria limited to OR in addition to?'",
'is_repeat' => "DEFAULT 0",
'is_active' => "DEFAULT 1 COMMENT 'Is this option active?'",
'record_activity' => "DEFAULT 0 COMMENT 'Record Activity for this reminder?'",
Expand Down
2 changes: 1 addition & 1 deletion ext/afform/admin/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-01-09</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>beta</develStage>
<compatibility>
<ver>5.23</ver>
Expand Down
2 changes: 1 addition & 1 deletion ext/afform/core/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-01-09</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>beta</develStage>
<compatibility>
<ver>5.23</ver>
Expand Down
2 changes: 1 addition & 1 deletion ext/afform/html/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-01-09</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>alpha</develStage>
<compatibility>
<ver>5.23</ver>
Expand Down
2 changes: 1 addition & 1 deletion ext/afform/mock/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-01-09</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<tags>
<tag>mgmt:hidden</tag>
</tags>
Expand Down
2 changes: 1 addition & 1 deletion ext/authx/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-02-11</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>alpha</develStage>
<compatibility>
<ver>5.0</ver>
Expand Down
2 changes: 1 addition & 1 deletion ext/civicrm_admin_ui/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2022-01-02</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>alpha</develStage>
<compatibility>
<ver>5.47</ver>
Expand Down
2 changes: 1 addition & 1 deletion ext/civigrant/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-11-11</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.47</ver>
Expand Down
2 changes: 1 addition & 1 deletion ext/ckeditor4/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">https://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-05-23</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.39</ver>
Expand Down
2 changes: 1 addition & 1 deletion ext/contributioncancelactions/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-10-12</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.32</ver>
Expand Down
2 changes: 1 addition & 1 deletion ext/eventcart/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-08-03</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<tags>
<tag>mgmt:hidden</tag>
</tags>
Expand Down
2 changes: 1 addition & 1 deletion ext/ewaysingle/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-10-07</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<tags>
<tag>mgmt:hidden</tag>
</tags>
Expand Down
2 changes: 1 addition & 1 deletion ext/financialacls/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-08-27</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.30</ver>
Expand Down
2 changes: 1 addition & 1 deletion ext/flexmailer/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-08-05</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>stable</develStage>
<comments>
FlexMailer is an email delivery engine which replaces the internal guts
Expand Down
2 changes: 1 addition & 1 deletion ext/greenwich/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-07-21</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<tags>
<tag>mgmt:hidden</tag>
</tags>
Expand Down
2 changes: 1 addition & 1 deletion ext/legacycustomsearches/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-07-25</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>stable</develStage>
<tags>
<tag>mgmt:hidden</tag>
Expand Down
2 changes: 1 addition & 1 deletion ext/message_admin/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-06-12</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<tags>
<tag>mgmt:hidden</tag>
</tags>
Expand Down
2 changes: 1 addition & 1 deletion ext/oauth-client/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-10-23</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.38</ver>
Expand Down
2 changes: 1 addition & 1 deletion ext/payflowpro/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-04-13</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.0</ver>
Expand Down
2 changes: 1 addition & 1 deletion ext/recaptcha/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-04-03</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<tags>
<tag>mgmt:hidden</tag>
</tags>
Expand Down
2 changes: 1 addition & 1 deletion ext/search_kit/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-01-06</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.38</ver>
Expand Down
2 changes: 1 addition & 1 deletion ext/sequentialcreditnotes/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2020-01-28</releaseDate>
<version>5.49.1</version>
<version>5.49.2</version>
<tags>
<tag>mgmt:hidden</tag>
</tags>
Expand Down
2 changes: 1 addition & 1 deletion sql/civicrm_generated.mysql
Original file line number Diff line number Diff line change
Expand Up @@ -2933,7 +2933,7 @@ UNLOCK TABLES;
LOCK TABLES `civicrm_domain` WRITE;
/*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES
(1,'Default Domain Name',NULL,'5.49.1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
(1,'Default Domain Name',NULL,'5.49.2',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
/*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down
2 changes: 1 addition & 1 deletion sql/test_data_second_domain.mysql
Original file line number Diff line number Diff line change
Expand Up @@ -908,4 +908,4 @@ INSERT INTO civicrm_navigation
VALUES
( @domainID, CONCAT('civicrm/report/instance/', @instanceID,'&reset=1'), 'Mailing Detail Report', 'Mailing Detail Report', 'administer CiviMail', 'OR', @reportlastID, '1', NULL, @instanceID+2 );
UPDATE civicrm_report_instance SET navigation_id = LAST_INSERT_ID() WHERE id = @instanceID;
UPDATE civicrm_domain SET version = '5.49.1';
UPDATE civicrm_domain SET version = '5.49.2';
2 changes: 0 additions & 2 deletions xml/schema/Core/ActionSchedule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
<html>
<label>Limit To</label>
</html>
<default>1</default>
<required>true</required>
<add>4.4</add>
</field>
<field>
Expand Down
2 changes: 1 addition & 1 deletion xml/version.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
<version>
<version_no>5.49.1</version_no>
<version_no>5.49.2</version_no>
</version>