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

Add link to Plugin Editor for each found issue to jump user to file and line of code #298

Merged
merged 12 commits into from
Nov 1, 2023

Conversation

mukeshpanchal27
Copy link
Member

Closes #251

Checklist:

@mukeshpanchal27
Copy link
Member Author

This pull request adds the Plugin Editor link for all error/notice situations. However, there are certain cases where we need to exclude it:

  • If a plugin contains .phar or .gitignore files, the Plugin Editor does not support these formats, and clicking the link will display a Sorry, that file cannot be edited message.
  • If a plugin does not have a readme file, the plugin will display a no_plugin_readme message, but that file is not present in the folder, so it will show the same error as mentioned above.

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.

@mukeshpanchal27 mukeshpanchal27 marked this pull request as ready for review October 23, 2023 09:52
Copy link
Member

@felixarntz felixarntz left a 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.

@swissspidy
Copy link
Member

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?

@felixarntz
Copy link
Member

@swissspidy

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.

@mukeshpanchal27
Copy link
Member Author

@felixarntz @swissspidy, in the commit at 733479b, I have addressed all your concerns. Additionally, I have also added checks for the DISALLOW_FILE_EDIT constant, which many plugins use to disable the plugin editors. I have adjusted the result table accordingly.

Could you please review these changes once more? Thank you!

Copy link
Member

@felixarntz felixarntz left a 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.

includes/Traits/File_Editor_URL.php Outdated Show resolved Hide resolved
templates/results-row.php Outdated Show resolved Hide resolved
templates/results-row.php Outdated Show resolved Hide resolved
templates/results-table.php Outdated Show resolved Hide resolved
mukeshpanchal27 and others added 2 commits October 25, 2023 10:46
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Copy link
Member

@felixarntz felixarntz left a 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.

templates/results-row.php Outdated Show resolved Hide resolved
templates/results-row.php Outdated Show resolved Hide resolved
@mukeshpanchal27
Copy link
Member Author

@felixarntz @swissspidy @westonruter @joemcgill, I have addressed all the feedback, and the PR is now ready for review.

Copy link
Member

@swissspidy swissspidy left a 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

Comment on lines 30 to 32
if ( ! isset( $filename, $line ) ) {
return null;
}
Copy link
Member

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?

Copy link
Member

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 Show resolved Hide resolved
assets/js/plugin-check-admin.js Show resolved Hide resolved
assets/js/plugin-check-admin.js Show resolved Hide resolved
Comment on lines 30 to 32
if ( ! isset( $filename, $line ) ) {
return null;
}
Copy link
Member

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 Show resolved Hide resolved
includes/Traits/File_Editor_URL.php Outdated Show resolved Hide resolved
mukeshpanchal27 and others added 2 commits October 31, 2023 11:15
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Co-authored-by: Weston Ruter <westonruter@google.com>
Copy link
Member

@felixarntz felixarntz left a 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.

includes/Traits/File_Editor_URL.php Show resolved Hide resolved
@mukeshpanchal27
Copy link
Member Author

@westonruter, whenever you have some moment, could you please review this PR so that we can proceed with merging it? Thanks!

@mukeshpanchal27 mukeshpanchal27 merged commit 74bc890 into trunk Nov 1, 2023
12 checks passed
@mukeshpanchal27 mukeshpanchal27 deleted the fix/251-add-plugin-editor-link branch November 1, 2023 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add link to Plugin Editor for each found issue to jump user to file and line of code
4 participants