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

Revert civicrm_action_schedule.limit_to boolean column to be NULL #23477

Closed

Conversation

monishdeb
Copy link
Member

@monishdeb monishdeb commented May 17, 2022

Overview

Revert the boolean field civicrm_action_schedule.limit_to to be NULL and not required, to address issues https://lab.civicrm.org/dev/core/-/issues/3464 and https://lab.civicrm.org/dev/core/-/issues/3465

In my opinion, limit_to should be int with three options.

Comments

ping @agileware-justin @eileenmcnaughton @MegaphoneJon @colemanw

@monishdeb monishdeb added the 5.49 label May 17, 2022
@civibot
Copy link

civibot bot commented May 17, 2022

(Standard links)

@eileenmcnaughton
Copy link
Contributor

@monishdeb we need to merge to the 5.50 rc before we can merge to 5.49 stable - can you put up a PR against the rc too (this will be mergeable once that is merged, if no changes made to that one)

@monishdeb
Copy link
Member Author

Created PR for 5.50 rc #23478

@monishdeb monishdeb force-pushed the schedule-reminder-bool-fix branch from 31304d4 to 1581c76 Compare May 18, 2022 02:21
@totten
Copy link
Member

totten commented May 18, 2022

@monishdeb I would suggest a second commit based on:

./tools/bin/scripts/set-version.php 5.49.2 --commit

@monishdeb
Copy link
Member Author

monishdeb commented May 18, 2022

@monishdeb I would suggest a second commit based on:

./tools/bin/scripts/set-version.php 5.49.2 --commit

done :) ..thanks!

@totten
Copy link
Member

totten commented May 18, 2022

@monishdeb To try this, I created a 5.48 database with ~10 scheduled-reminders. Each reminder was in a different configuration status, eg

  • An example with limit_to="Neither" (null)
  • Two examples with limit_to="Also Include" (0) (one using "Select Group"; another using "Choose Recipients")
  • Three examples with limit_to="Limit To" (1) (one using "Select Group"; another using "Choose Recipients"; another using "Soft Credit")
  • A few examples which were initially saved as one thing (eg "Limit To") and then edited/downgraded to the simpler "Neither".

Then I used this DB snapshot with various upgrade paths, eg

  • 5.48.2 => 5.49.1
  • 5.48.2 => 5.49.1 => 5.49.2 (w/patch)
  • 5.48.2 => 5.49.2 (w/patch)

The results are here: https://gist.github.com/totten/7f43420108d4e40c4d1aabbda1763f1b

A few issues:

  • In 548-5492.txt, rows #11 and #12 both got munged values of limit_to. I think this could be fixed with an extra guard: if it's a direct upgrade from good-to-good (if limit_to is already nullable), then changeBooleanColumnLimitTo() should not do anything.
  • In 548-5491-5492.txt , rows #7, #8, #9, #10 got munged values of limit_to=0. Of course, this really happened in the 5.49.1 step, and I don't see how to fix those ones. However, perhaps we could give a notice to point people at records which should be re-considered?

@agileware-justin
Copy link
Contributor

agileware-justin commented May 18, 2022

If limit_to=NULL then group_id should also be set to NULL - to address https://lab.civicrm.org/dev/core/-/issues/3464#note_74627

If the limit_to value is 1 then remove the value of the Group ID field on save of the Scheduled Reminder form.

@monishdeb monishdeb force-pushed the schedule-reminder-bool-fix branch 2 times, most recently from b4a4c53 to 60ff732 Compare May 18, 2022 11:45
@monishdeb
Copy link
Member Author

@totten thanks for detailed report. I have addressed the first issue by adding an upgrade code for 5.49.0 and 2nd issue by adding pre and post upgrade message.

@agileware-justin I will address this bug in the master branch PR #23487

@monishdeb monishdeb force-pushed the schedule-reminder-bool-fix branch from 60ff732 to 1dcd81f Compare May 18, 2022 11:48
@monishdeb monishdeb force-pushed the schedule-reminder-bool-fix branch from 1dcd81f to ce1ef36 Compare May 18, 2022 12:48
public function upgrade_5_49_2($rev) {
if (version_compare(CRM_Core_BAO_Domain::version(), '5.49', '>=') {
public function upgrade_5_49_0($rev) {
if (version_compare(CRM_Core_BAO_Domain::version(), '5.49.beta1', '>=')) {
Copy link
Member

@totten totten May 18, 2022

Choose a reason for hiding this comment

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

Well... that was worth a try... In my r-run over each of the upgrade paths, it never seems to return TRUE, so it always skipped the step.

I think I found a hidden feature which can do what this is trying to do... but still putting it through the r-run...

Copy link
Member

Choose a reason for hiding this comment

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

Just to clarify that a bit...

What this line seems to ask: "Is the start-revision >= 5.49.beta1?" But Domain::version() doesn't tell you the start-revision. (It tells you the last-stored incremental update, which is a rolling-value during the upgrade process.)

However, the information is available. The upgrade_N_N_N() method can actually receive three parameters (upgrade_5_49_2($currentRev, $startRev, $finalRev)). The $startRev parameter is what this was looking for (aff7086).

Copy link
Member Author

Choose a reason for hiding this comment

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

Awesome, didn't knw that

@totten
Copy link
Member

totten commented May 19, 2022

Replaced by #23490, which starts from similar commits but adds a few more.

@totten totten closed this May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants