-
Notifications
You must be signed in to change notification settings - Fork 60
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
Add link to Plugin Editor for each found issue to jump user to file and line of code #298
Conversation
This pull request adds the Plugin Editor link for all error/notice situations. However, there are certain cases where we need to exclude it:
I would appreciate hearing your thoughts on this matter before proceeding with the exclusion of these files or any other files that may require exclusion. |
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.
@mukeshpanchal27 This mostly looks good, though there's one critical problem as this is missing current_user_can( 'edit_plugins' )
checks (also see #262 (comment)).
We must only show these links if the current user has the permission to edit plugins via the built-in file editor - which is something that is often not the case as many environments disable it.
Should we still show the link if the link has been filtered to point to another editor like VS Code? |
Good point, that would make sense. |
Co-authored-by: Weston Ruter <westonruter@google.com>
@felixarntz @swissspidy, in the commit at 733479b, I have addressed all your concerns. Additionally, I have also added checks for the Could you please review these changes once more? Thank you! |
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.
Thanks @mukeshpanchal27 for making the updates, sharing a bit of follow up feedback below.
We may need to holistically determine for each table whether or not to include a column for the edit link, by checking for whether any of the rows include a non-empty link.
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
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.
@mukeshpanchal27 Two points of follow up feedback regarding the markup.
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
@felixarntz @swissspidy @westonruter @joemcgill, I have addressed all the feedback, and the PR is now ready for review. |
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.
One question, otherwise looks good
includes/Traits/File_Editor_URL.php
Outdated
if ( ! isset( $filename, $line ) ) { | ||
return null; | ||
} |
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.
The phpdoc for $filename
and $line
don't indicate that they can be nullable. Therefore, is this condition valid? If it is, then should they be modified to be nullable in the phpdoc?
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.
Fair point, I think we should remove this. If we include checks like this just because someone could pass null
(due to lack of parameter type hints), we would need to do that in almost every function.
I do however have another related suggestion: Several of our checks are not line-specific, as in the message data doesn't include a line (or rather have the line set to 0
). I think it would make sense to give $line
a default value of 0
to clarify that it is optional, and then the method logic could be adjusted to not pass line
if it doesn't have an actual (i.e. not 0
) value.
includes/Traits/File_Editor_URL.php
Outdated
if ( ! isset( $filename, $line ) ) { | ||
return null; | ||
} |
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.
Fair point, I think we should remove this. If we include checks like this just because someone could pass null
(due to lack of parameter type hints), we would need to do that in almost every function.
I do however have another related suggestion: Several of our checks are not line-specific, as in the message data doesn't include a line (or rather have the line set to 0
). I think it would make sense to give $line
a default value of 0
to clarify that it is optional, and then the method logic could be adjusted to not pass line
if it doesn't have an actual (i.e. not 0
) value.
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
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.
Thank you @mukeshpanchal27 for the updates, LGTM!
One other comment below, but I think we should solve that in a separate issue/PR.
@westonruter, whenever you have some moment, could you please review this PR so that we can proceed with merging it? Thanks! |
Closes #251
Checklist: