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

issue#5726 : Revert "Fix ActionSchedule save on repeat events" #32255

Open
wants to merge 1 commit into
base: 6.0
Choose a base branch
from

Conversation

monishdeb
Copy link
Member

@monishdeb monishdeb commented Feb 28, 2025

Overview

https://lab.civicrm.org/dev/core/-/issues/5726

Before

On using 'Repeat Activity' at the bottom of the Activity edit screen and save, you get the following error and only the original Activity is saved:

Mandatory values missing from Api4 ActionSchedule::save: start_action_unit, mapping_id

After

Correctly saved.

Technical Details

This reverts commit 0f589cef49495bebcd1fb97ba5ef76385bd9586b . It works with CRM_Core_BAO_ActionSchedule::writeRecord() because it doesn't pass through validator but when we use save action it eventually hits the validator and throw the error message:

Civi\Api4\Generic\AbstractSaveAction->validateValues() | /Users/monish/src/civicrm-core/Civi/Api4/Generic/DAOSaveAction.php:40
Civi\Api4\Generic\DAOSaveAction->_run(Object(Civi\Api4\Generic\Result)) | /Users/monish/src/civicrm-core/Civi/Api4/Provider/ActionObjectProvider.php:91
Civi\Api4\Provider\ActionObjectProvider->invoke(Object(Civi\Api4\Generic\DAOSaveAction)) | /Users/monish/src/civicrm-core/Civi/API/Kernel.php:153
Civi\API\Kernel->runRequest(Object(Civi\Api4\Generic\DAOSaveAction)) | /Users/monish/src/civicrm-core/Civi/Api4/Generic/AbstractAction.php:256
Civi\Api4\Generic\AbstractAction->execute() | /Users/monish/src/civicrm-core/CRM/Core/Form/RecurringEntity.php:366
CRM_Core_Form_RecurringEntity::postProcess(Array, 'civicrm_activity', Array) | /Users/monish/src/civicrm-core/CRM/Activity/Form/Activity.php:1009

It failed for mapping_id and start_action_unit values because these have following required_if condition:

  1. Mapping ID - empty($values.used_for) || $values.used_for !== "civicrm_event"
  2. Start action unit - empty($values.absolute_date) && (empty($values.used_for) || $values.used_for !== "civicrm_event")
    The actual record which is passed to ActionSchedule::save action here is :
2025-02-28 09:37:23+0000  [info] $dbParams = Array
(
    [used_for] => civicrm_activity
    [entity_value] => 664
    [start_action_date] => 20250228092200
    [repetition_frequency_unit] => week
    [repetition_frequency_interval] => 1
    [start_action_condition] => sunday,monday
    [start_action_offset] => 2
)

I think that required_if condition is bit incorrect in this case as we have the user_for value but since its not civicrm_event it will always fail and and the start_action_unit should also check for start_action_date along with absolute date ?

So I suppose the validators should be :

  1. Mapping ID - empty($values.used_for) || ($values.used_for !== "civicrm_event" && $values.used_for !== "civicrm_activity")
  2. Start action unit - empty($values.absolute_date) && empty($values.start_action_date) && (empty($values.used_for) || ($values.used_for !== "civicrm_event" && $values.used_for !== "civicrm_activity"))

If you agree with this logic I will submit a separate PR against master and submit another PR dependent on it restore Eilieen;s commit.

Comments

ping @colemanw @eileenmcnaughton @seamuslee001

Copy link

civibot bot commented Feb 28, 2025

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot bot added the 6.0 label Feb 28, 2025
@monishdeb monishdeb changed the title Revert "Fix ActionSchedule save on repeat events" issue#5726 : Revert "Fix ActionSchedule save on repeat events" Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant