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

Rename duplicated terms in tcontact.obo #1907

Merged
merged 5 commits into from
Jun 22, 2024

Conversation

dsenalik
Copy link
Contributor

@dsenalik dsenalik commented Jun 19, 2024

Bug Fix

Closes #1906

Tripal Version: 4.x

Description

This renames the two duplicated terms to be unique, and renames a third term for consistency. See more details in linked issue #1906
Also, this file had DOS style line endings, so converted this. See commit eb58f33 to more clearly see the actual changes.

Testing?

Build a docker
Add a new contact
Enter "%Departmen" for the type, the autocomplete should offer
2024-06-19_newDepartment

Change to "%Organizatio"
2024-06-19_newOrganization

@dsenalik dsenalik added Tripal 4 Any issue or pull request focused on Tripal 4 Group 1 - Tripal Content Types | Terms | Fields Any issue relating to Tripal Content including types, terms, and fields. labels Jun 19, 2024
Copy link
Member

@laceysanderson laceysanderson left a comment

Choose a reason for hiding this comment

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

I think it would also be good to also change/add a definition to make it clear that these are specifically related to the contact (i.e. properties). The other terms with the same name are intended to be the type of contact.

Affiliated Department: The department of the institution or organization that the contact is affiliated with.

Affiliated Institution: The employer (e.g. company, university, corporation) that the contact is affiliated with.

Affiliated Organization: The formal group of people the contact is affiliated with. Organizations differ from institutions by being more focused on people coming together for a specific purpose; where as, institutions usually refer to physical locations of a particular corporation.

@spficklin
Copy link
Member

Have we always been able to use the % character in an autocomplete? Does that get fed into the SQL query? If so, that really makes me nervous. I think that characters is benign but can you give it others and hack the query?

@dsenalik
Copy link
Contributor Author

That's a very good question @spficklin that I had not thought about.
You could do this in Tripal 3 also
2024-06-21_autocomplete

The good news is that the database abstraction layer will handle sanitization for a condition() method as long as the user input is not used to select the operation -
Writing secure code for Drupal / Use the database abstraction layer to avoid SQL injection attacks
There is an example there of how to prevent use of the wildcard character, but because it is highly useful for the autocomplete we would not want to do that.

Our code, where $name comes from the autocomplete input, is

    if (array_key_exists('exact', $options) and $options['exact'] === True) {
      $query1->condition('CVT.name', $name, '=');
    }
    else {
      $query1->condition('CVT.name', $name . '%', 'LIKE');
    }

@laceysanderson
Copy link
Member

I think based on the code that it is safe to continue allowing this for the autocompletes :-)

The updated definitions look perfect @dsenalik <3
Do we also want an update hook to change these term names in existing chado instances?

@dsenalik
Copy link
Contributor Author

I did not think we would need an update hook, because if we do the Chado prepare step when migrating, it will change these terms.

Copy link
Member

@laceysanderson laceysanderson left a comment

Choose a reason for hiding this comment

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

😮 So you are right -no need for an update hook for this one.

I finally found the time to test this. I created a docker on the 4.x branch and queried to confirm that I had the old version of the department term:

2956	tripal_contact	Department
2963	tripal_contact	Department(TCONTACT:0000016)

Then I switched to this branch and ran the prepare again. The prepare ran again without an error. Then I queried the terms again.

2956	tripal_contact	Department
2963	tripal_contact	Affiliated Department

@laceysanderson laceysanderson merged commit 6f9be42 into 4.x Jun 22, 2024
15 checks passed
@laceysanderson laceysanderson deleted the tv4g4-issue1906-tcontact-remove-duplicate-terms branch June 22, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group 1 - Tripal Content Types | Terms | Fields Any issue relating to Tripal Content including types, terms, and fields. Tripal 4 Any issue or pull request focused on Tripal 4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate terms in tcontact.obo
3 participants