Make WordPress Core

Opened 5 years ago

Last modified 2 years ago

#54339 new defect (bug)

unique $keys array when add custom key from Several places with postmeta_form_keys

Reported by: myousefi08 Owned by:
Priority: normal Milestone: Awaiting Review
Component: Options, Meta APIs Version: 5.8.1
Severity: normal Keywords: reporter-feedback
Cc: Focuses: administration

Description

I added two similar custom key from my theme and a plugin with postmeta_form_keys filter.
but now display both of theme in custom-fields name's select box (custom-fields metabox - post.php or post-new.php)
I think is better to unique $keys before options are printed.

wp-admin/includes/template.php
line ~730

before:
foreach ( $keys as $key ) {

after:
$keys = array_unique($keys);
foreach ( $keys as $key ) {

Change History (1)

#1 @desrosj
2 years ago

  • Component GeneralOptions, Meta APIs
  • Keywords reporter-feedback added

Hi @myousefi08 and welcome to Trac!

My apologies that it took so long to receive a response.

To make sure I understand the report. You're saying you have a filter in both your plugin and theme that adds two identical meta keys to the list of keys to display using postmeta_form_keys?

If that's the case, that should not result in duplicates. They should be filtered out since the meta query performed includes DISTINCT. If this is what you're seeing, could you please provide some more details and maybe a code snippet that another contributor could use to reproduce the problem?

I'm marking as this a close candidate with a worksforme resolution because I've been unable to reproduce the report as I understand it.

Note: See TracTickets for help on using tickets.