Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#53102 closed defect (bug) (fixed)

Incorrect documentation for delete_{$meta_type}_meta and deleted_{$meta_type}_meta filter hooks

Reported by: pputzer's profile pputzer Owned by: davidbaumwald's profile davidbaumwald
Milestone: 5.9 Priority: normal
Severity: normal Version: 5.4
Component: Options, Meta APIs Keywords: good-first-bug has-patch
Focuses: docs Cc:

Description

The inline documentation for delete_{$meta_type}_meta and deleted_{$meta_type}_meta incorrectly states that the $_meta_value parameter is Serialized if non-scalar (from [47390]). While $meta_value is run through maybe_serialize, $_meta_value is not.

Also, I think the hook documentation should make it clear that the meta value is only passed from the optional function argument, so it might not contain anything meaningful.

Attachments (1)

53102.diff (3.1 KB) - added by hasanuzzamanshamim 3 years ago.
Removed "Serialized if non-scalar"

Download all attachments as: .zip

Change History (6)

#1 @pputzer
3 years ago

On further investigation, the issue may stem at least partially from the to separate uses of the hook in delete_metadata and delete_metadata_by_mid. The latter uses get_metadata_by_mid to retrieve the current values before deleting the metadata. The meta value is still not serialized, though.

I think the best solution would be to read the actual meta values in delete_metadata as well.

#2 @SergeyBiryukov
3 years ago

  • Component changed from General to Options, Meta APIs
  • Milestone changed from Awaiting Review to 5.8

#3 @desrosj
3 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from 5.8 to 5.9

The beta 1 deadline is today. Since this one does not yet have a patch, I am going to punt to 5.9. However, documentation changes are allowed during the beta part of the release cycle. If someone is able to create a patch before 29 June, it can be moved back.

@hasanuzzamanshamim
3 years ago

Removed "Serialized if non-scalar"

#4 @hasanuzzamanshamim
3 years ago

  • Keywords has-patch added; needs-patch removed

#5 @davidbaumwald
3 years ago

  • Owner set to davidbaumwald
  • Resolution set to fixed
  • Status changed from new to closed

In 52140:

Options, Meta APIs: Correct docs for $_meta_value parameter in xxx_{$meta_type}_meta hooks.

In add_{$meta_type}_meta, added_{$meta_type}_meta, update_{$meta_type}_meta, updated_{$meta_type}_meta, delete_{$meta_type}_meta, and deleted_{$meta_type}_meta hooks, the $_meta_value parameter was documented as "Serialized if non-scalar". However, $_meta_value is a copy of the raw meta value before maybe_serialize is run and is not serialized. This change updates each of the above hooks' docblocks to remove "Serialized if non-scalar" from the $_meta_value parameter description.

Props pputzer, hasanuzzamanshamim.
Fixes #53102.

Note: See TracTickets for help on using tickets.