Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#22191 closed defect (bug) (fixed)

In update_metadata(), compare old/new values before deciding whether to call add_metadata()

Reported by: nacin's profile nacin Owned by: markjaquith's profile markjaquith
Milestone: 3.5 Priority: normal
Severity: normal Version:
Component: Performance Keywords: has-patch
Focuses: Cc:

Description (last modified by nacin)

In update_metadata(), we query for a meta_id of an existing key. If it exists, we continue. If we get nothing back, we call add_metadata().

We also compare the old value with the new value, and if they are the same, we bail.

Since that old value is from cache, it is possible for update_metadata() to not run a single query on its own if there is nothing to update. Only, we do, because we do the meta_id query first.

We should do the meta_id query second. This is the same pattern used by update_option().

Related: #22192, the strict type comparison causes false negatives.

Attachments (1)

22191.diff (1002 bytes) - added by nacin 12 years ago.

Download all attachments as: .zip

Change History (3)

#1 @nacin
12 years ago

  • Description modified (diff)

@nacin
12 years ago

#2 @markjaquith
12 years ago

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

In [22231]:

Defer the meta_id-fetching query until after comparison of the previous value, so that redundant calls to update_metadata() can bail without making that query. props nacin. fixes #22191

Note: See TracTickets for help on using tickets.