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-21433: Optimize dupe checking in Recent Items stack #11281

Merged
merged 1 commit into from
Dec 2, 2017

Conversation

niels-heinemann
Copy link
Contributor

@niels-heinemann niels-heinemann commented Nov 15, 2017

Don't check for dupes by url beacause query params my change their order. Instead use type and id.


@mlutfy
Copy link
Member

mlutfy commented Nov 15, 2017

Hi,

Can you open a JIRA issue? https://docs.civicrm.org/dev/en/latest/core/contributing/

Also, can you provide examples of what would normally create a dupe, so that we can test before & after?

From a code style point of view, it seems to me like using === over == does not add any benefits in that case? (but makes the reader stop and wonder why === was used).

@eileenmcnaughton
Copy link
Contributor

i think === is supposed to be what you should use unless there is a reason not to - e.g you think there is a risk of a number being passed as a string

@niels-heinemann niels-heinemann changed the title Optimize dupe checking in Recent Items stack CRM-21433: Optimize dupe checking in Recent Items stack Nov 15, 2017
@niels-heinemann
Copy link
Contributor Author

Issue filed at https://issues.civicrm.org/jira/browse/CRM-21433.

I just produced some dupes while implementing #11280. In one case I injected an activity item with query params reset=1&id={$this->_activityId}&action=view and in another I changed the order to action=view&reset=1&id=$activityId without thinking about it.

== was a typo (by me ;) in a PR before and I fixed it here. It's just like @eileenmcnaughton said, === is the default way to go when trying to achieve kind of type safety.

@mlutfy
Copy link
Member

mlutfy commented Nov 15, 2017

Call me pedantic, but I am not able to reproduce the bug.

For example, I tried accessing:

And only one contact was shown in the Recent Items.

Am I missing something obvious? (the old code clearly seems wrong)

@niels-heinemann
Copy link
Contributor Author

niels-heinemann commented Nov 15, 2017

Yeah. It's not the request's query params order which is passed. It's the programmer's order at the place Recent.php's add-method is called! See

$url = CRM_Utils_System::url(implode("/", $this->urlPath), "reset=1&id={$activityId}&action=view& cid={$values['source_contact_id']}");
  CRM_Utils_Recent::add($this->_values['subject'],
	  $url,
              [...]
  );

@colemanw
Copy link
Member

colemanw commented Dec 2, 2017

This makes sense to me.

@colemanw colemanw merged commit a1a82eb into civicrm:master Dec 2, 2017
sluc23 pushed a commit to ixiam/civicrm-core that referenced this pull request Jan 10, 2018
CRM-21433: Optimize dupe checking in Recent Items stack
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.

5 participants