Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@spficklin
Copy link
Member

@spficklin spficklin commented Jun 18, 2018

Issue #452 and #355

Type(s) of Change(s)

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • API-specific change (fix or addition to an API function)
  • Updates documentation (inline or markdown files)

Description

There were two problems with using tokens in URLs.

First, the tokens were not "deep" enough. For example, when setting the URL for a gene or mRNA content type you had available the [obi__organism] token but that was it! There was nothing for the genus and species. If you used it then it an empty string would be substituted for the token. This pull request fixes that problem. Now, the tokens reference the sub elements of a field so we now have tokens for genus and species. Tokens should exist for any field that has sub elements and those elements are defined in the elementInfo() function of the field.

Second, non alphanumeric characters were being rewritten as underscores. That causes problems with migrating from Tv2 aliases.

Finally, I fixed a typo in the TripalJob class that I discovered while testing this fix. It was preventing me from re-running jobs. Just take a look at the code below and you'll see the problem. The if statement tries to evaluate the $path but it is set in the line below:

$includes = $details['includes'];
if ($path and is_array($path)) {
foreach ($includes as $path) {
$full_path = $_SERVER['DOCUMENT_ROOT'] . base_path() . $path;

Testing

The easiest test is to edit the gene content type and set the URL alias to this:
mRNA/[obi__organism,TAXRANK:0000005]/[obi__organism,TAXRANK:0000006]/[data__identifier]
Before using that URL string, check the 'Available Tokens' to make sure you see the tokens used in the string above.

It will take time to update your URLs if you have thousands of records. So, testing on a small site or different content type would go fastest.

Screenshots (if appropriate):

Additional Notes (if any):

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@spficklin spficklin added tripal-7.x-3.x Priority - Release Blocker Any issue/PR which needs to be addressed before another version of Tripal can be released. labels Jun 18, 2018
@almasaeed2010
Copy link
Contributor

Note that this PR fixes issue #469

@almasaeed2010
Copy link
Contributor

While testing this PR, I get the following fatal error when I visit /admin/content/bio_data:

Error messagePDOException: SQLSTATE[42703]: Undefined column: 7 ERROR: column tripal_entity.label does not exist LINE 1: ....id AS entity_id, tripal_entity.bundle AS bundle, tripal_ent... ^: SELECT tripal_entity.id AS entity_id, tripal_entity.bundle AS bundle, tripal_entity.label AS tripal_entitylabel, tripal_entity.changed AS tripal_entitychanged, :entity_type AS entity_type, NULL AS revision_id FROM {tripal_entity} tripal_entity WHERE (tripal_entity.bundle = :db_condition_placeholder_0) ORDER BY tripal_entity.label ASC, tripal_entity.changed DESC LIMIT 25 OFFSET 0; Array ( [:db_condition_placeholder_0] => bio_data_1 [:entity_type] => TripalEntity ) in tripal_content_overview_form() (line 330 of /Sites/Tripal/sites/all/modules/tripal/tripal/includes/TripalEntityUIController.inc).

@bradfordcondon
Copy link
Member

i made a PR that fixes this and it has been merged on master. i think you can safely ignore assuming theres not a commit that reverts it in this pr. #458

@almasaeed2010
Copy link
Contributor

(I meant to add the following comment here but went to another issue by mistake oops!)

Ok I reviewed your PR against this and I don't see the issue being reintroduced. Merging this to master should not revert the PR made by @bradfordcondon 👍

@laceysanderson
Copy link
Member

Ok, Added the Reviewer #1 Approval tag for @almasaeed2010's review --Thanks!

One more review required before merge...

@bradfordcondon
Copy link
Member

Code looks good to me. I followed your example (replacing mrna with gene in the url) and the job ran successfully.
However I would think that for a gene with ID Contig10011, for Fraxinus excelsior, the below url should be the new location. However I get a page not found error?

http://localhost:8083/gene/Fraxinus/excelsior/Contig10011

@bradfordcondon
Copy link
Member

NONE of the URL aliases work on my site. We checked my url_alias table and it looks good there.

Since @almasaeed2010 has functional confirmation, and the code looks good to me, i'm going to aprove given our discussion re: number of required functional tests.

@bradfordcondon bradfordcondon merged commit aa2e2d3 into 7.x-3.x Jun 22, 2018
@bradfordcondon bradfordcondon deleted the 452-tv3-token_issues branch June 22, 2018 18:55
@spficklin
Copy link
Member Author

That's odd the URLs didn't work for you and warrants investigation if you have time. Thanks for merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority - Release Blocker Any issue/PR which needs to be addressed before another version of Tripal can be released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants