-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Issue _doing_it_wrong() when registered style has invalid path and allow empty stylesheets to be inlined
#10653
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
Closed
Closed
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9828bac
Issue _doing_it_wrong() when invalid path is provided to registered s…
westonruter 9c7273c
Add test coverage for file read error
westonruter 295efcc
Ensure stylesheets of zero size can be inlined
westonruter 8cb36ca
Remove redundant test and add missing expectedIncorrectUsage tag
westonruter ce80e7a
Ensure built CSS files are present in tests
westonruter 8cc52a2
Use is_readable() instead of error suppression
westonruter 16f8e46
Touch more styles
westonruter 23debdb
Touch stub CSS files in wp-includes which are created from build process
westonruter 15d5bd8
Improve ensuring CSS files are present during tests
westonruter 4ceb527
Add fail-fast for testing
westonruter 5d1ba9f
Ensure wp-emoji-loader.js is present for test_wp_hoist_late_printed_s…
westonruter a7660a9
Add assertion to ensure wp-block-library was printed
westonruter 1f8a2f8
Ensure wp-block-library-theme is created
westonruter f4694aa
Add yet more debug code
westonruter d3fbff0
Improve ensuring that wp-block-library is not empty
westonruter 5c5912a
Revert "Add fail-fast for testing"
westonruter 46afeb7
Remove debug code
westonruter 7152b33
Remove conditional setting of path data
westonruter 7e0f735
Fix grammar
westonruter 4b94b3b
Merge branch 'trunk' into trac-64447
westonruter 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
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
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
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.
Note that
wp_filesize()returns0both when the path is invalid and when the file has a zero size. So thisfile_exists()check here ensures that an empty stylesheet can be inlined.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.
There's no reason to inline an empty stylesheet, is there? I suspect the falsy check here is appropriate.
This is interesting, is
wp_filesizehere intended to be an optimization where filters can be used to avoid hitting the filesystem?I tend to use
is_readable()for checks like this.Strictly considering the logic, I think ideally this would be:
I think this would make it very difficult to hit a warning on the
file_get_contentsbelow, although not impossible.I see
wp_filesize()usesfilesizewhich issues a warning if the file isn't present, but I think those will be handled by the readable check.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.
It's better to inline an empty stylesheet as opposed to wastefully loading it as a blocking resource. Right?
This may conflict with the original purpose for introducing the
pre_wp_filesizefilter. If the intention is to bypass the filesystem, then adding the separate! is_readable()check first would conflict with that. I see this was introduced in r52837.I think
file_exists()is better because this is whatwp_filesize()specifically is using to return0.That said, I've added 8cc52a2 to use
is_readable()instead of using error suppression.