WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#14828 closed enhancement (fixed)

Database query for non-existent mods_themename option

Reported by: demetris Owned by: nacin
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.1
Component: Performance Keywords: needs-refresh commit
Focuses: Cc:

Description

I have noticed this in Twenty Ten and in a couple of other themes, but I imagine it must be the same for any theme for which the mods_themename option applies:

Unless you have visited one of the Menus, Background, etc. screens, and have modified something there, the mods_themename option is not added to the DB. As a result, WordPress does not find it in the autoloaded set and has to query the DB.

Attachments (1)

14828.diff (506 bytes) - added by nacin 7 years ago.

Download all attachments as: .zip

Change History (12)

#1 @nacin
7 years ago

  • Milestone changed from Awaiting Review to 3.1

Let's try to add it when a theme gets activated.

#2 @demetris
7 years ago

My thought as I was filing the ticket was that this would be an one-liner fix if we had a hook for theme activation.

Open tickets for theme activation hook:

#7795

#13602

#3 @jane
7 years ago

  • Keywords needs-patch added

Can we try to resolve this by freeze (a few days from now)? Will also ping Ian Stewart and see if he can weigh in.

#4 @nacin
7 years ago

  • Owner set to nacin
  • Status changed from new to accepted

#5 @nacin
7 years ago

  • Keywords has-patch added; needs-patch removed

We had decided to avoid messing with switch_theme() in #15048, but to avoid the extra query, here's an attempt.

#6 @nacin
7 years ago

  • Type changed from defect (bug) to enhancement

@nacin
7 years ago

#7 @iandstewart
7 years ago

Looks good to me.

#8 @westi
7 years ago

  • Milestone changed from 3.1 to Future Release

This is going to do an add_option on a front-page load.

We try and avoid those.

Moving out of 3.1 to Future Release

#9 @markjaquith
7 years ago

  • Milestone changed from Future Release to 3.1

For later:

if ( is_admin() )
    add_option( "theme_mods_" . $stylesheet, (array) get_option( "mods_" . $theme ) );

#10 @nacin
7 years ago

  • Keywords needs-refresh commit added; has-patch removed

#11 @nacin
7 years ago

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

(In [16958]) Add theme_mods option if is_admin. props MarkJaquith, fixes #14828.

Note: See TracTickets for help on using tickets.