Make WordPress Core

Opened 4 months ago

Closed 3 months ago

Last modified 2 months ago

#64539 closed task (blessed) (fixed)

Deprecate the `addslashes_gpc()` function

Reported by: johnbillion's profile johnbillion Owned by: westonruter's profile westonruter
Milestone: 7.0 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch has-unit-tests commit add-to-field-guide needs-dev-note
Focuses: Cc:

Description (last modified by johnbillion)

The addslashes_gpc() function is just a wrapper for wp_slash(). It should be moved to deprecated.php and deprecated to help reduce confusion about magic quoting, which is where this function originated.

There are some uses of addslashes_gpc() that need to be switched to wp_slash() too.

Change History (9)

#1 @johnbillion
4 months ago

  • Description modified (diff)

This ticket was mentioned in PR #10771 on WordPress/wordpress-develop by @rutviksavsani.


4 months ago
#2

  • Keywords has-patch has-unit-tests added; needs-patch removed

In this pull request, we are deprecating the addslashes_gpc function as it was just a wrapper function to wp_slash
Additionally, I have added PHPUnit tests for the same as well, let me know if they are not required and I can remove it.

Trac ticket: https://core.trac.wordpress.org/ticket/64539

#3 @westonruter
4 months ago

  • Keywords commit added

@rutviksavsani commented on PR #10771:


3 months ago
#4

@audrasjb @westonruter @mindctrl Thanks for the reviews.
Who would be the best person to merge this to the SVN?

@westonruter commented on PR #10771:


3 months ago
#5

I'm happy to do so.

#6 @westonruter
3 months ago

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

#7 @westonruter
3 months ago

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

In 61590:

Formatting: Deprecate the addslashes_gpc() function.

This deprecates addslashes_gpc() in favor of wp_slash(), as the former is just a wrapper for the latter. The three remaining uses of addslashes_gpc() (in WP_Query) have been replaced with wp_slash(). Unit tests are added to verify that they have the same behavior.

Developed in https://github.com/WordPress/wordpress-develop/pull/10771

Follow-up to [23591], [23555].

Props rutviksavsani, audrasjb, westonruter, mindctrl, johnbillion.
See #21767.
Fixes #64539.

#8 @audrasjb
2 months ago

  • Keywords add-to-field-guide needs-dev-note added

This is worth mentioning in the Field Guide.
Also adding needs-dev-note just in case we can mention it in a more general note.

#9 @westonruter
2 months ago

I drafted a dev note section for the field guide: https://docs.google.com/document/d/1PpVQE9kuNE0KWfQxUQKfrbzfuRBkuSg6Sz7-NUWCsKI/edit?tab=t.0

I wanted to take the opportunity to provide context for why this function was needed and why wp_slash() is still needed, since authors can still liable to pass unslashed data to functions that require it.

Related: https://github.com/WordPress/WordPress-Coding-Standards/issues/172

Note: See TracTickets for help on using tickets.