Interactivity: Fix string index warning#6257
Interactivity: Fix string index warning#6257sirreal wants to merge 7 commits intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
30b12f4 to
704bd40
Compare
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
👋 @c4rl0sbr4v0 @DAreRodz for review. |
src/wp-includes/interactivity-api/class-wp-interactivity-api.php
Outdated
Show resolved
Hide resolved
|
Possible to add tests for this? |
|
I tried adding tests and would like to, but I couldn't get them to fail on the warning, that may be a configuration option or my lack of knowledge, but I couldn't find any way of saying "warnings on this test should cause the test to fail." There is actually a test that has a short attribute and should hit this code path, but it doesn't fail the test suite or seem to generate any warning: |
|
Good catch! I pushed a change to apply the same fix to that warning. |
|
You also need a test like the one I shared to trigger the warning in the second updated line. The value needs to be |
|
I pushed a test that does error if I revert the changes. |
|
I'll address the test failures. |
|
I fixed the tests and updated them to use This is something to address across the interactivity tests when comparing strings to strings. |
gziolo
left a comment
There was a problem hiding this comment.
Excellent, tests pass locally. I no longer see the warnings. I could confirm that unit tests hit both conditions by manually changing the comparisons strlen( $bound_attribute ) > 5 using value 1.
|
Committed in https://core.trac.wordpress.org/changeset/57835 |

Fix the following warning when using an interactivity bind directive with a short attribute name, e.g.
wp-data-bind--id.Trac ticket: https://core.trac.wordpress.org/ticket/60758
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.