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

CRM-21391 Convert Case to use core Task class #11759

Merged
merged 1 commit into from
Mar 5, 2018

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Mar 5, 2018

Overview

Refactor case task form to use base class

Before

localhost_8000_civicrm_case_search__qf_search_display true qfkey 45cb1c9a5c8aef3e5c13be1dfa0ceaae_2825 1

After

localhost_8000_civicrm_case_search__qf_search_display true qfkey 45cb1c9a5c8aef3e5c13be1dfa0ceaae_2825

Technical Details

details in #11240

Comments

This is a commit from #11240

In terms of review check that the code was a positive improvement and tested a couple of actions as well as checking the same number of actions were present


@eileenmcnaughton
Copy link
Contributor

This one seems pretty straight forward & an agreed improvement, merging

@eileenmcnaughton eileenmcnaughton merged commit e654e51 into civicrm:master Mar 5, 2018
@mlutfy mlutfy added this to the 4.7.32 milestone Mar 6, 2018
if (!self::$_tasks) {
self::$_tasks = array(
1 => array(
self::TASK_DELETE => array(
Copy link
Member

@totten totten Mar 7, 2018

Choose a reason for hiding this comment

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

@mattwire @eileenmcnaughton @colemanw (https://docs.civicrm.org/dev/en/latest/standards/review/#r-tech) - Doesn't this break anything that listens to hook_civicrm_searchTasks by virtue of changing the numbers?

Don't get me wrong... the old values are magic-numbers that don't make sense. They seem like a design-flaw. Lots of extensions use the idiom $tasks[] = array(...), which is more robust.

But... the example in the docs specifically uses the technique:

https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_searchTasks/#example

And there are multiple examples in universe where hook_civicrm_searchTasks references numerical IDs/existing constants (biz.jmaconsulting.bugp/bugp.php, biz.jmaconsulting.printgrantpdfs/printgrantpdfs.php, civicrm-drupal-6.x/civitest.module.sample, uk.co.compucorp.civicrm.giftaid/civigiftaid.php). Anecdotally, I remember needing to do similar things in Civi 2.x (basically, as long as the hook has existed).

(Note: This isn't a pointed critique of #11759 -- it generally applies to all the offspring of #11240.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@totten Yes there is a chance it could break some extensions. However, the numeric indexes have been a bit inconsistent throughout versions and shouldn't really be relied on - once all the "Task" PRs are merged we'll have a consistent set of constants that extension authors can use, meaning that their extensions won't break in the future! If we can get them all merged before the 5.0.0 release we can have something in the release notes making extensions authors aware that they may need to tweak the searchTask constants if using hardcoded values in their extensions.

Copy link
Contributor

Choose a reason for hiding this comment

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


if (!empty($this->_formValues['case_deleted'])) {
unset($tasks[1]);
unset($tasks[CRM_Case_Task::DELETE]);
Copy link
Member

Choose a reason for hiding this comment

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

@mattwire @eileenmcnaughton change here cause regression as it should be TASK_DELETE

Steps to replicate:

  1. Go to Find Cases
  2. Try to search deleted cases
Error: Undefined class constant 'DELETE' in CRM_Case_Form_Search->buildQuickForm() (line 180 of /Users/monish/src/civicrm/CRM/Case/Form/Search.php).

Copy link
Contributor

Choose a reason for hiding this comment

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

@monishdeb is that tracked somewhere?

(ie. a) good point thanks for letting us know but b) is fixing this under control ?)

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.

6 participants