Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#50635 closed enhancement (fixed)

Deprecate wp_slash_strings_only() in favour of wp_slash()

Reported by: ocean90's profile ocean90 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.6 Priority: normal
Severity: normal Version: 5.5
Component: Formatting Keywords: has-patch
Focuses: rest-api Cc:

Description

Since [48433] wp_slash() no longer changes non-string types which was the main reason for the introduction of wp_slash_strings_only() in [46454]. To avoid confusion we should deprecate wp_slash_strings_only().

Attachments (1)

50635.patch (2.9 KB) - added by ayeshrajans 4 years ago.
Deprecates wp_slash_strings_only() and addslashes_strings_only() functions, and then replaces the single use of those functions with wp_slash; Tests: https://travis-ci.com/github/Ayesh/wordpress-develop/builds

Download all attachments as: .zip

Change History (10)

#1 @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 5.6

@ayeshrajans
4 years ago

Deprecates wp_slash_strings_only() and addslashes_strings_only() functions, and then replaces the single use of those functions with wp_slash; Tests: https://travis-ci.com/github/Ayesh/wordpress-develop/builds

#2 @ayeshrajans
4 years ago

  • Keywords has-patch added; needs-patch removed

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


4 years ago

#5 @SergeyBiryukov
4 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#6 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 49188:

Formatting: Deprecate wp_slash_strings_only() in favor of wp_slash().

The reason for introducing wp_slash_strings_only() in [46454] was to keep non-string values untouched.

Later, wp_slash() itself was updated in [48433] to prevent changing non-string values.

To avoid confusion, wp_slash_strings_only() is now deprecated.

Props ayeshrajans, ocean90.
Fixes #50635.

#7 follow-up: @garrett-eclipse
4 years ago

Should references of wp_slash_strings_only be removed from the WordPress Importer phpunit data?
When you install from svn the wordpress-importer dir is installed to the tests/phpunit/data/plugins and the wordpress-importer/class-wp-import.php contains references to wp_slash_strings_only, as well there's a pluggable wp_slash_strings_only function in the wordpress-importer/compat.php.
Thanks

#8 in reply to: ↑ 7 ; follow-up: @SergeyBiryukov
4 years ago

Replying to garrett-eclipse:

Should references of wp_slash_strings_only be removed from the WordPress Importer phpunit data?
When you install from svn the wordpress-importer dir is installed to the tests/phpunit/data/plugins and the wordpress-importer/class-wp-import.php contains references to wp_slash_strings_only, as well there's a pluggable wp_slash_strings_only function in the wordpress-importer/compat.php.

Good catch, thanks! I think the plugin can be left as is for now, as it aims to be compatible with WP 3.7+, and the fix for wp_slash() to handle non-string values is only available since WP 5.5.

That said, the plugin could probably be updated to call wp_slash() on WP 5.5+, and wp_slash_strings_only() on older versions.

#9 in reply to: ↑ 8 @garrett-eclipse
4 years ago

Replying to SergeyBiryukov:

That said, the plugin could probably be updated to call wp_slash() on WP 5.5+, and wp_slash_strings_only() on older versions.

Thanks @SergeyBiryukov I've opened a ticket on the plugin repo here;
https://github.com/WordPress/wordpress-importer/issues/83

Note: See TracTickets for help on using tickets.