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

XWIKI-22702: Provide parentType information in EntityReference #3698

Merged
merged 5 commits into from
Dec 3, 2024

Conversation

surli
Copy link
Member

@surli surli commented Nov 27, 2024

Jira URL

https://jira.xwiki.org/browse/XWIKI-22702

Changes

Description

  • Provide EntityReference#getParentType
  • Use it in AbstractReferenceEntityReferenceResolver
  • Provide a new test

Clarifications

Screenshots & Video

Executed Tests

Expected merging strategy

  • Prefers squash: Yes
  • Backport on branches:
    *

@surli surli self-assigned this Nov 27, 2024
@surli surli requested a review from tmortagne November 27, 2024 13:56
@surli surli force-pushed the entityreference-parenttype branch from 7ab07dd to f9bf262 Compare November 27, 2024 16:20
@surli surli changed the title [TBD] Allow to resolve relative entity references properly XWIKI-22702: Provide parentType information in EntityReference Nov 27, 2024
this.parameters = null;
}
}
}

private void setParentTypeParameter(Serializable value)
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that I hesitated here between silently ignoring the arguments or throwing an IllegalArgumentException when there was a parent or when the value wasn't an allowed parent type. I decided to go for the silent solution because it's easier to create a reference by using EntityReference#replaceParent (which is what we use in the resolver): the parameter is just automatically ignored.

Copy link
Member Author

Choose a reason for hiding this comment

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

We also perform this kind of silent ignore for the locale parameter.

Copy link
Member

Choose a reason for hiding this comment

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

silent ignore for the locale parameter

Not really, if the format of the locale String is wrong, you will get an IllegalArgumentException.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, I improved a bit the method to have more checks. Note that I'm still skipping setting the parameter value is parent != null, but this check remains silent. wdyt @tmortagne ?

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with the silent ignore when value != null && getParent() == null.

surli added 2 commits December 2, 2024 11:12
  * Provide EntityReference#getParentType
  * Use it in AbstractReferenceEntityReferenceResolver
  * Provide a new test
  * Use the new information in RelativeStringEntityReferenceResolver
  * Fix tests
@surli surli force-pushed the entityreference-parenttype branch from f9bf262 to 1835f09 Compare December 2, 2024 10:15
  * revert some changes from last commit
  * add more explanatory tests
  * Change the parameter name
  * Improve a bit the checks when setting the fallbackParentType
    parameter value
  * use back parentType parameter key name
@surli surli merged commit c5b9c60 into master Dec 3, 2024
1 check passed
@surli surli deleted the entityreference-parenttype branch December 3, 2024 11:16
Copy link

github-actions bot commented Dec 3, 2024

The backport to stable-16.10.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-stable-16.10.x stable-16.10.x
# Navigate to the new working tree
cd .worktrees/backport-stable-16.10.x
# Create a new branch
git switch --create backport-3698-to-stable-16.10.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 c5b9c6051462122a37d8e7001c4776abed599ea8
# Push it to GitHub
git push --set-upstream origin backport-3698-to-stable-16.10.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-stable-16.10.x

Then, create a pull request where the base branch is stable-16.10.x and the compare/head branch is backport-3698-to-stable-16.10.x.

surli added a commit that referenced this pull request Dec 10, 2024
  * Provide EntityReference#getParentType
  * Use it in AbstractReferenceEntityReferenceResolver
  * Provide a new test
  * add more explanatory tests
  * Improve a bit the checks when setting the fallbackParentType
    parameter value
  * use back parentType parameter key name

(cherry picked from commit c5b9c60)
surli added a commit that referenced this pull request Dec 10, 2024
  * Provide EntityReference#getParentType
  * Use it in AbstractReferenceEntityReferenceResolver
  * Provide a new test
  * add more explanatory tests
  * Improve a bit the checks when setting the fallbackParentType
    parameter value
  * use back parentType parameter key name

(cherry picked from commit c5b9c60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants