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
Validate the ID target for symlinks #14041
Conversation
The current
Another thing I noticed. If I have an existing resource with id |
Thank you for feedback @JoshuaLuckers. I agree, the text needs to be adjusted. I am still a bit unsure if this is an enhancement we want though. I'll wait to see what Jason and Mark says :) I can also expand the validation by adding a check that validates that the input is a number. |
Maybe it should be a warning instead of an error. |
A few thoughts:
|
Good points, I'll try to implement this! |
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.
Minor tweak - as @Jako also mentioned, this is an alternative way to require the provided content to be an integer ID. Makes it a bit more explicit than the filter_var
approach imo.
I wondering is it possible to use traits here to avoid code duplication? |
My issues with this PR should be fixed with these changes. |
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.
👍
* upstream/pr/14041: Add lexicon entries Check integer value & add modWebLink check Check integer value & add modWebLink check Validate the ID target for symlinks
@Jako awesome work man :) Thanks for taking the time to fix it. |
This is a problem unfortunately as this PR causes a significant BC break. The target of a symlink or weblink can be a MODX tag that is evaluated at runtime and this destroys the ability to maintain those. |
I mean that the target value can be |
Yes, and those will be ignored, because there is not really any good way to validate them. This PR only validates if the user enters an integer value. |
I tried to look at the code, but I do not have the time to properly investigate this now. I suspect one of the filters is incorrect. |
The weblink code checks for an integer and validates afterwards, since it could be an external link. The Symlink code validates only, if it is an integer. Thats the issue here. |
What does it do?
This PR attempts to introduce validation for symlink targets. The symlinks needs to specify an existing resource in the system, and it is fairly easy to check if the user misspelled their target value.
The check is implemented for both update and create processors.
Note: I have left out the validation when you change the class type. If you have a modDocument, and then decide to change it into a modSymLink, we would attempt to validate the value of the content field. This can be anything, and would most likely produce a lot of errors and problems for the developers. Because of that, we only validate resources that are NEW modSymLinks, or when the user attempts to save an existing modSymLink. Also note that we do not validate that the field has any values, as this has previously not been required.
Why is it needed?
It adds a sanity check that I think only improves usability.
Related issue(s)/PR(s)
#10141