-
-
Notifications
You must be signed in to change notification settings - Fork 827
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
Fix activity view bug where an activity type id in the url overrides … #27496
Conversation
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
@@ -65,7 +69,6 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { | |||
*/ | |||
protected $_sourceContactId; | |||
protected $_targetContactId; | |||
protected $_asigneeContactId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
CRM/Activity/Form/Activity.php
Outdated
@@ -265,33 +268,20 @@ public function preProcess() { | |||
|
|||
$this->assign('context', $this->_context); | |||
|
|||
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this); | |||
$this->setAction(CRM_Utils_Request::retrieve('action', 'String', $this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once #27495 is merged it will cast to an int & we can be confident it is numeric
I can review this but there's a lot going on here and if I remember right this area was a bit fraught with danger. And I think case activity calls this too. |
43ea66f
to
8781048
Compare
@demeritcowboy yeah - your tests found the danger - I'm pulling it back ... |
8781048
to
4377104
Compare
@@ -9,7 +9,7 @@ | |||
*} | |||
<div class="crm-block crm-content-block crm-activity-view-block"> | |||
{if $activityTypeDescription} | |||
<div class="help">{$activityTypeDescription}</div> | |||
<div class="help">{$activityTypeDescription|escape}</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no direct reason - but the temptation to change how this is loaded is there so this is hardening in case that happens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to try to look at this this weekend but just noting that this field is html so purify seems more better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
4377104
to
ff6107d
Compare
test this please |
|
||
// cleanup | ||
$this->callAPISuccess('option_value', 'delete', ['id' => $result['id']]); | ||
$form = $this->getTestForm('CRM_Activity_Form_Activity', [], ['atype' => 800, 'cid' => $this->source]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get a fail here because action is null, so I think it just needs to add 'action' => 'add'
to the params. But also while it's a nice addition to check the template vars, what this test was about was checking that somebody doesn't mess up $form->_activityTypeName
(line 267).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@demeritcowboy I've pushe dup the fix - but I am trying to avoid checking properties & check what the form outputs instead - the property is 'public' but ... not really. It's an internal form property - but what the form outputs is the variable....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since removing the existing coverage isn't necessary for fixing the bug and the discussion around public vars gets into scope creep, I'd suggest a compromise to add your test as a new test, which adds some good coverage, and then this would be good to merge (with the other test fail about the action
url param addressed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@demeritcowboy actually the way I make it work to test the form is by switching to the form test wrapper - which gives a better level of testing - but it explicitly doesn't allow testing properties - other than where they have publicly supported getter methods
templates/CRM/Case/Form/Activity.tpl
Outdated
@@ -25,7 +25,7 @@ | |||
<table class="form-layout"> | |||
{if $activityTypeDescription } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is where it needs a rebase.
templates/CRM/Case/Form/Case.tpl
Outdated
@@ -27,7 +27,7 @@ | |||
<table class="form-layout"> | |||
{if $activityTypeDescription } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also a rebase here.
ff6107d
to
bd0a9b7
Compare
bd0a9b7
to
355f76b
Compare
@demeritcowboy this kinda fell off the radar but I just rebased it since that seemed to be the issue.... |
Right. The other issue was that it changes what the existing test was testing which I'd like to keep, and that change isn't necessary to fix the bug. If it's added as a new test then this is an easy merge. |
@demeritcowboy are you wanting to keep the test on that property because you are accessing the property from an extension? The form-test methodology is deliberately biased against testing properties that are not supported for external use as part of trying to test the contract rather than things that are really internal to the form. We have been adding supported functions like |
Ok what I'll do is take the test and move it to an extension and run it elsewhere. So there's just the action param problem - I guess it's expecting CRM_Core_Action::ADD instead although that feels wrong. |
@demeritcowboy I can add in the I'm not totally clear on the action one - what do we need to do |
Oh it's a different test failing than before. CRM_Case_BAO_CaseTest::testGetRelatedCases now needs to set For this test, the name and docblock should be changed since that's not what it's testing anymore. It's now testing the smarty template variable. |
ffe3408
to
09f7a34
Compare
jenkins retest this please This PR seems to keep growing... |
I moved |
CRM/Activity/Form/Activity.php
Outdated
|
||
if ($this->_action & CRM_Core_Action::DELETE) { | ||
$action = CRM_Utils_Request::retrieve('action', 'String', $this); | ||
if ($action === 'add') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't needed. Request::retrieve
already does this hack.
As a general comment, I think this is unfair. This should be a 3 line PR, and now I have to r-run it again, and I've already spent a few hours reviewing it several times. All that had to happen on the last revision to get a merge was to add one line to one of the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh gawd you are right - my head was just spinning on how it was working & I couldn't see it - I'll take this out again
09f7a34
to
cedc609
Compare
…the actual activity type id When we view an activity there is code in the template that renders differently depending on the activity type id. However, if the activity ID (atype) is wrong in the url it gives the url precedence This is a bit obscure - I hit it when I changed the activity type id in the database & the view did not update
cedc609
to
c69cd9b
Compare
Thanks @demeritcowboy - sorry this was such a drag |
Overview
Fix activity view bug where an activity type id in the url overrides the actual activity type id
When we view an activity there is code in the template that renders differently depending on the activity type id. However, if the activity ID (atype) is wrong in the url it gives the url precedence
This is a bit obscure - I hit it when I changed the activity type id in the database & the view did not update
Before
Create an activity with details
(might need to save directly to DB UPDATE - no through the UI works)
View the activity - it looks like
Alter the activity view url - put the activity type ID for pdf letter (default install = 22 ) into the url as
atype
- you get the unadulterated versionAfter
The activity type ID comes from the activity not the url
Technical Details
A bit of minor clean up too
Comments