-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Site Health false positive: WP_DEBUG_LOG warning when debug.log is outside wp-content - Ticket #64071 #10684
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
Open
hbhalodia
wants to merge
8
commits into
WordPress:trunk
Choose a base branch
from
hbhalodia:fix/issue-64071
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+28
−10
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f99e009
CoreTrac-64071 Show different warning if debug.log is publicly access…
hbhalodia bcebdf8
CoreTrac-64071 Update the wordings and code structure
hbhalodia 3749fef
CoreTrac-64071 Add the directory separator to absolute path to preven…
hbhalodia 8636002
CoreTrac-64071 Update wordings in message to show in site-health for …
hbhalodia ffda9d8
CoreTrac-64071 Check the directory of log instead of checking file
hbhalodia b98ece6
CoreTrac-64071 Fix phpcs error
hbhalodia 2da8e22
CoreTrac-64071 Update the debug_log_path to use error_log config
hbhalodia 97e37bd
Merge branch 'trunk' into fix/issue-64071
hbhalodia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should this be changed?
Uh oh!
There was an error while loading. Please reload this page.
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.
Amm, I thought so as well, but I have kept it as is. This is because the current condition will only provide us if
WP_DEBUG_LOGis set or not, and that is enough here for a check. Ultimately we are usingini_get( 'error_log' )to get the error_log config.IMO, there is no harm to change this, and also there is no harm to keep as is, as ultimately the output that we need would be same.
Also if we need to consider a performance check, IMO reading from constant would be faster, then calling a function for the same and then toggling the condition via
! empty.So for first thing,
defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOGa simple constant hashlookup, while for this,! empty( ini_get( 'error_log' ) ), a function call to check for value, then check for empty and then toggle condition. Still it's very negligible difference.I am okay to accomodate the above change, but there is no requirement in it unless you see something specific?
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 performance here doesn't matter since it's only when the Site Health tests runs, right? It's not running with request.
My concern is if a server is misconfigured to have an
error_logwet to somewhere in the document root (ABSPATH), even ifWP_DEBUG_LOGisn't being set.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.
Yes it won't have much impact related to performance, but thought to raise. We can neglect this.
If I am understanding correctly, you are saying anyhow someone have set this debug file to use document root, that is, from somewhere they call this,
ini_set( 'error_log', 'path-to-document-without-wp-debug-log-constant' )without explicitly setting the constant value, So in this case, our condition would failif ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {, and it would show the false information.But that could ever happen? Because let's say
WP_DEBUG_LOGis not set and somehow the error_log with document root path is configured, then we are never outputing user thatyou have enabled debug_log as good practice, instead we would say the default message,Your site is not set to output debug information, though this is misleading as error_log is configured and we need to provide information that it is good practice or not based on the path.Also, if we use
! empty( ini_get( 'error_log' ) )it as a condition, the point would again be misleading because we would show whatever message need to show based on path, but we are saying to user that, 'The constant,WP_DEBUG_LOG.....' is set but that is not set as per the edge case we are assuming.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.
Consider this case: someone may not define
WP_DEBUG_LOGat all, but theirwp-config.phpmay have this:This would not be detected as a problem currently in Site Health test, but it would be a similar problem, as if there are any
error_log()calls being made, they'll go to that public file. The same issue would happen if the php.ini was set with anerror_logset to a public location, right?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 @westonruter, Yes agreeing to the point, Concerning part here is below message to me,
It say's 'The constant,
WP_DEBUG_LOG, has been added to this website’s configuration file', but as per the example shared, theWP_DEBUG_LOGis not actually being set, the error log is added by this statement,ini_set( 'error_log', __DIR__ . '/error-log.txt' );, So we need to change the statement here to more generic.Ideally if I am a user and see's this message, I will first check this constant,
WP_DEBUG_LOG, and I would not able to find how this is set (but actually that is not set as per example), hence I would not get an idea that it was set from server or somewhere else.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.
Agreed. We could have a separate message when the
WP_DEBUG_LOGconstant is set, and then another general one about theerror_logbeing misconfigured.