Opened 5 months ago
Last modified 4 months ago
#63572 new defect (bug)
theme.json file variable could be a directory, add check to prevent notices
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | trunk |
| Component: | Themes | Keywords: | has-patch needs-test-info |
| Focuses: | Cc: |
Description
In class-wp-theme-json-resolver.php
is the line
if ( is_readable( $theme_json_file ) ) {
However if the $theme_json_file is a directory that will return true, even if it expects a .json local file path.
In this patch I propose adding is_file ( and perhaps even removing is_readable, as is_readable will also return true for directories ).
Change History (3)
This ticket was mentioned in PR #8988 on WordPress/wordpress-develop by @ramon fincken.
5 months ago
#1
#2
@
4 months ago
- Keywords needs-test-info added
Hi @ramon-fincken
Can you please include step by step instructions how to reproduce this and test the patch?
(As in first creating a directory called theme.json, what issue is being prevented, what are the notices, and what the expected outcome of the patch is.)
#3
@
4 months ago
If this is added in themes/themename/resources
array_map ( 'add_filter', [ 'theme_file_path', 'theme_file_uri', 'parent_theme_file_path', 'parent_theme_file_uri', ], array_fill ( 0, 4, 'dirname' ) );
The call will fail without that file check.
I agree this is an error on the theme developers end, therefore we as WP Core must insert an improved "if" handler.
In this patch I propose adding is_file ( and perhaps even removing is_readable, as is_readable will also return true for directories ).
Trac
https://core.trac.wordpress.org/ticket/63572#ticket