Repository navigation
Tests: Cover stripslashes_from_strings_only() - #15325
devmuhib009 wants to merge 2 commits into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
huzaifaalmesbah
left a comment
There was a problem hiding this comment.
I left a few small notes inline.
AI Review: Opus 5.5
| 'float' => array( 3.14 ), | ||
| 'boolean true' => array( true ), | ||
| 'null' => array( null ), | ||
| 'array' => array( array( 'a', 'b' ) ), |
There was a problem hiding this comment.
This one looks like a small coverage gap: array( 'a', 'b' ) has nothing to strip, so the test still passes if array items start getting stripped. A slashed item would catch it:
| 'array' => array( array( 'a', 'b' ) ), | |
| 'array' => array( array( "I can\'t", 'b' ) ), |
| * | ||
| * @ticket 65819 | ||
| * | ||
| * @covers ::stripslashes_from_strings_only |
There was a problem hiding this comment.
Optional: the class docblock already has @covers ::stripslashes_from_strings_only. Feel free to drop this one and the one at line 76.
There was a problem hiding this comment.
🟡 Changes recommended
The array fixture contains no backslashes, so the assertion cannot detect incorrect recursive stripping and needs a backslash-containing string to verify that non-string inputs remain unchanged.
1 open issue
What changed in this PR
This PR extends WordPress formatting tests to cover stripslashes_from_strings_only(), addressing Trac ticket #65819 without changing production code.
Changes:
- Adds a test verifying slash removal from strings.
- Adds data-driven checks that non-string values remain unchanged.
- Adds coverage annotations for the helper.
| File | Description |
|---|---|
tests/phpunit/tests/formatting/stripslashesDeep.php |
Adds string and non-string tests for stripslashes_from_strings_only(). |
Review effort: Balanced
lancewillett
left a comment
There was a problem hiding this comment.
Please narrow the added coverage. test_strips_slashes() already exercises this callback through stripslashes_deep(), and test_preserves_original_datatype() already protects integer/boolean preservation. The added string case repeats that regression check. Remove the duplicate string case and avoid repeating the scalar matrix solely for direct coverage. The direct-array contract is distinct, but the current unslashed array does not distinguish it; the existing inline feedback already explains that limitation. Removing redundant additions is sufficient—no additional test matrix is requested.
AI review · gpt-6
…ve array contract.
huzaifaalmesbah
left a comment
There was a problem hiding this comment.
Thanks for refining this, @devmuhib009! Narrowing the test to stripslashes_from_strings_only()'s non-recursive array contract removes redundancy and cleanly verifies the unique behavior. LGTM!
AI Review: Gemini 3.8 Flash
lancewillett
left a comment
There was a problem hiding this comment.
The narrowed test now distinguishes the documented behavior: an array containing a slashed string must pass through stripslashes_from_strings_only() unchanged. The existing recursive tests never pass an array directly to that callback. Removing the duplicate string/scalar cases was useful simplification.
The affected class passes randomized single-site and multisite runs (4 tests, 15 assertions each); PHPCS and CI pass. A controlled callback mutation passed the older tests but failed this new assertion. Approved at 728bb7b.
AI review · gpt-6
Verify that `stripslashes_from_strings_only()` leaves an array containing a slashed string unchanged. The existing `stripslashes_deep()` tests exercise recursive processing instead of this direct-input contract. Developed in: #15325 Props devmuhib, huzaifaalmesbah. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@65188 602fd350-edb4-49c9-b593-d223f7449a82
Verify that `stripslashes_from_strings_only()` leaves an array containing a slashed string unchanged. The existing `stripslashes_deep()` tests exercise recursive processing instead of this direct-input contract. Developed in: WordPress/wordpress-develop#15325 Props devmuhib, huzaifaalmesbah. See #65819. Built from https://develop.svn.wordpress.org/trunk@65188 git-svn-id: http://core.svn.wordpress.org/trunk@64337 1a063a9b-81f0-0310-95a4-ce76da25c4cd
|
PR #15325 landed in https://core.trac.wordpress.org/changeset/65188 |

Trac ticket: https://core.trac.wordpress.org/ticket/65819
This PR extends
Tests_Formatting_StripslashesDeepto coverstripslashes_from_strings_only():