[wp-trac] [WordPress Trac] #53566: Pass the asset path to the `_doing_it_wrong()` notice in `register_block_script_handle()`
WordPress Trac
noreply at wordpress.org
Wed Jan 25 22:58:29 UTC 2023
#53566: Pass the asset path to the `_doing_it_wrong()` notice in
`register_block_script_handle()`
-------------------------------------------------+-------------------------
Reporter: desrosj | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.2
Component: Script Loader | Version:
Severity: normal | Resolution:
Keywords: good-first-bug has-patch needs- | Focuses:
testing changes-requested |
-------------------------------------------------+-------------------------
Changes (by ironprogrammer):
* keywords: good-first-bug has-patch needs-testing => good-first-bug has-
patch needs-testing changes-requested
Comment:
Thank you for the progress so far, @neychok! This PR needs some work, and
could use a refresh against `trunk`. Hopefully we can see some traction on
this before the coming beta 🤞🏻.
As @desrosj [#ticket pointed out], `$script_asset_path` is `false` when
the asset file is missing, so changes are needed to capture the missing
asset path to provide to `_doing_it_wrong()`.
----
I might suggest the following test instructions and acceptance criteria
for this ticket (and happy to update the provided test plugin if these
change):
== Testing Instructions
=== Steps to Reproduce or Test
1. In your test site, ensure that `WP_DEBUG` and `WP_DEBUG_LOG` are
enabled.
2. Install the
[https://gist.github.com/ironprogrammer/314c2d6af804043ec33841f72cbfca36
test plugin located here] on your test site (gist includes instructions).
3. In a browser, open or refresh the homepage on your test site.
4. Inspect the logged PHP notice that begins with `PHP Notice: Function
register_block_script_handle was called <strong>incorrectly</strong>.`
=== Expected Results
When reproducing existing behavior:
- ❌ The PHP notice does not contain the expected missing path:
The asset file for the "script" defined in "unit-tests/test-block" block
definition is missing.
When testing a patch to validate it works as expected:
- ✅ The PHP notice should contain the expected path to the missing
`.asset.php` file derived from `$metadata['script']`:
The asset file "blocks/notice/missing-asset.asset.php" for the "script"
defined in "unit-tests/test-block" block definition is missing.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53566#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list