WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#11373 closed enhancement (fixed)

get_page_by_path() enhancements

Reported by: Denis-de-Bernardy Owned by: ryan
Milestone: 3.1 Priority: normal
Severity: normal Version: 2.9
Component: Cache API Keywords: early has-patch commit gsoc
Focuses: Cc:

Description

The attached file works around a few queries in get_page_by_path() when memcached is used on a site, by trying to fetch page parents in the object cache before fetching the needed data in the database.

Attachments (2)

11373.diff (785 bytes) - added by Denis-de-Bernardy 6 years ago.
11373.2.diff (820 bytes) - added by wojtek.szkutnik 5 years ago.

Download all attachments as: .zip

Change History (15)

@Denis-de-Bernardy6 years ago

comment:2 @nacin5 years ago

  • Milestone changed from 3.0 to Future Release

comment:3 follow-ups: @dd325 years ago

Is there any good reason why get_page() or get_post() couldnt be used inside that loop to take care of the query & caching?

comment:4 in reply to: ↑ 3 @Denis-de-Bernardy5 years ago

  • Keywords commit added
  • Milestone changed from Future Release to 3.0

Replying to dd32:

Is there any good reason why get_page() or get_post() couldnt be used inside that loop to take care of the query & caching?

Depends if you want to do a SELECT * or not... This one can safely get checked in, I've been using it on my own site for months.

comment:5 @nacin5 years ago

  • Keywords early added
  • Milestone changed from 3.0 to 3.1

comment:6 in reply to: ↑ 3 @shidouhikari5 years ago

  • Cc shidouhikari added

Replying to dd32:

Is there any good reason why get_page() or get_post() couldnt be used inside that loop to take care of the query & caching?

get_page() is used below, when desired page is found. While it's not found, database is queried inside 2 TWO loops over and over again searching for the desired page. And when that's the case, all we need is post_parent, post_name and ID.

If that post is in cache, there's no need to query database, just get it from cache and move on. Faster and secure. I vote for this patch to be commited :)

comment:7 @sean2125 years ago

  • Version changed from 2.9 to 3.0

comment:8 @nacin5 years ago

  • Version changed from 3.0 to 2.9

Please don't change reported versions. They should reflect the version used in the report, or in cases where it is researched, the earliest instance where the report applies.

comment:9 @hakre5 years ago

See also: #14357

comment:10 @wojtek.szkutnik5 years ago

  • Cc wojtek.szkutnik@… added

Patch refreshed. +1 on this one

@wojtek.szkutnik5 years ago

comment:11 @wojtek.szkutnik5 years ago

  • Keywords gsoc added

comment:12 @nacin5 years ago

  • Milestone changed from Awaiting Triage to 3.1

This looks good.

comment:13 @ryan5 years ago

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

(In [16206]) Eliminate some queries in get_page_by_path() by consulting cache. Props Denis-de-Bernardy, wojtek.szkutnik. fixes #11373

Note: See TracTickets for help on using tickets.