Make WordPress Core

Opened 14 years ago

Closed 13 years ago

#16267 closed enhancement (duplicate)

update_post_meta doesn't differenciate between multiple identical values

Reported by: moskjis's profile moskjis Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.1
Component: General Keywords: has-patch
Focuses: Cc:

Description

If you would try update_post_meta(<post id>, 'key_1', 'Sad', 'Happy'); on

[key_1] => 'Happy'
[key_1] => 'Sad'
[key_1] => 'Happy'
[key_2] => 'Gregory'
[my_key] => 'Steve'

you would get

[key_1] => 'Sad'
[key_1] => 'Sad'
[key_1] => 'Sad'
[key_2] => 'Gregory'
[my_key] => 'Steve'

At the moment there is no way to change only second 'Happy'.

Added a patch to change this. Updated functions:

  1. update_post_meta, update_metadata: added a new, optional parameter <meta id>. If it's set, only the key with specified id is updated.
  2. update_meta_cache: for get_post_custom mainly - so one could get the id's without need to go into database.

Attachments (1)

post_meta.patch (3.6 KB) - added by moskjis 14 years ago.

Download all attachments as: .zip

Change History (5)

@moskjis
14 years ago

#1 @kawauso
14 years ago

  • Keywords has-patch added

#2 @scribu
14 years ago

Alternative: #10905

#3 @nacin
14 years ago

Meta_id ideally should be entirely internal and never exposed, so I'd probably prefer the approach in #10905.

#4 @ryan
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

See #18195

Note: See TracTickets for help on using tickets.