-
-
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
dev/core#4144 Fix smarty notice on isDuplicate #25657
Conversation
No issue was found matching the number given in the pull request title. Please check the issue number. |
(Standard links)
|
* Name of button for saving matching contacts. | ||
* @var string | ||
*/ | ||
protected $_duplicateButtonName; |
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 just muddies the waters using a property
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 agree, strange choice
9e9ce4a
to
5ae6078
Compare
This passed but I rebased to keep it fresh - seems like an infra issue test this please |
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.
The template could use one more little change to simplify it further
* Name of button for saving matching contacts. | ||
* @var string | ||
*/ | ||
protected $_duplicateButtonName; |
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 agree, strange choice
@@ -261,6 +257,18 @@ protected static function handleDuplicateChecking(&$errors, $fields, $form) { | |||
return $errors; | |||
} | |||
|
|||
/** | |||
* Is this being called from an entity reference field. |
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.
helpful explanation
@@ -35,7 +35,7 @@ | |||
<div id="crm-container" class="crm-container crm-public" lang="{$config->lcMessages|truncate:2:"":true}" xml:lang="{$config->lcMessages|truncate:2:"":true}"> | |||
{/if} | |||
|
|||
{if $isDuplicate and ( ($action eq 1 and $mode eq 4 ) or ($action eq 2) or ($action eq 8192) ) } | |||
{if array_key_exists('_qf_Edit_upload_duplicate', $form) && $isDuplicate} | |||
<div class="crm-submit-buttons"> | |||
{$form._qf_Edit_upload_duplicate.html} |
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.
Seems odd that we hard-code the button name here, and go to the trouble to generate it dynamically in Form.php... but if it works, fine
@@ -35,7 +35,7 @@ | |||
<div id="crm-container" class="crm-container crm-public" lang="{$config->lcMessages|truncate:2:"":true}" xml:lang="{$config->lcMessages|truncate:2:"":true}"> | |||
{/if} | |||
|
|||
{if $isDuplicate and ( ($action eq 1 and $mode eq 4 ) or ($action eq 2) or ($action eq 8192) ) } | |||
{if array_key_exists('_qf_Edit_upload_duplicate', $form) && $isDuplicate} |
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.
Does this not change the logic?
($action eq 1 and $mode eq 4 )
: ADD and MODE_CREATE
$action eq 2
: UPDATE
$action eq 8192
: PROFILE
I can't grok why we need to test for these; $isDuplicate should be enough, I'd think.
And array_key_exists('_qf_Edit_upload_duplicate', $form)
should always be TRUE.
So can we just change this to {if $isDuplicate}
?
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.
@highfalutin the reason for the button check is that the button is ONLY there under a very narrow situation - if you use an entity reference field & choose (e.g) new Organization AND choose an organization that exists THEN the button appears
Now trying to do a run, but I can't find where to trigger these notices. What form should I go to? |
@highfalutin they occur when using profiles - I'm not sure how intolerant your set up has to be but I saw another php 8.x user try to fix it & I definitely see it when I turn on smarty hardening - https://docs.civicrm.org/dev/en/latest/security/outputs/#html |
OK, for me the notices only show up if I view the form in its own tab, instead of as a modal. Smarty hardening doesn't need to be turned on for the notices to appear. Side note: I was a bit confused by the mention of "entity reference" -- the special "New Individual" and "New Organization" links don't appear on Entity Reference/Contact Reference custom fields, only on built-in fields built with BeforeOpen a profile edit page like Several notices appear, including:
The same notices appear when AfterIn To get both lines to disappear in both contexts: diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php
index 5bb2cf99d8..e8c8d9bdc4 100644
--- a/CRM/Profile/Form.php
+++ b/CRM/Profile/Form.php
@@ -904,10 +904,11 @@ class CRM_Profile_Form extends CRM_Core_Form {
$this->freeze();
}
+ // Assign FALSE, here - this is overwritten during form validation
+ // if duplicates are found during submit.
+ CRM_Core_Smarty::singleton()->assign('isDuplicate', FALSE);
+
if ($this->isEntityReferenceContactCreateMode()) {
- // Assign FALSE, here - this is overwritten during form validation
- // if duplicates are found during submit.
- CRM_Core_Smarty::singleton()->assign('isDuplicate', FALSE);
$this->addElement(
'xbutton',
$this->getButtonName('upload', 'duplicate'), I also took out the |
Thanks @highfalutin - I'll make the changes you suggest once I have fulfilled my chauffeur duties... |
…nother couple notices
just made a PR to your PR 😆 |
fix notice in non-dialog mode too, make var name clearer, fix another notice
OH wow - I got sooo confused - I thought your PR was against master & then I thought this must be already merged but then it wasn't and then my son sang 'I'm Slim Shady' & my brain broke |
I've given the merge-on-pass based on the review / collaboration from @highfalutin |
@Eileen we'll have to credit Eminem in the next release 🤣 |
lol |
Overview
dev/core#4144 Fix smarty notice on isDuplicate
Before
After
Technical Details
It was really hard to figure out the point of this variable / how it was reached. Most of the change is code commentary to try to make that clearer
The way
isDuplicate
comes into play is that duplicate checking is done if (& only if) the profile is used in the context of creating a new (e.g) individual from an entity reference fieldComments