Opened 10 years ago
Closed 9 years ago
#36952 closed defect (bug) (fixed)
get_theme_mod called when getting the root value of a custom type
| Reported by: | jontis | Owned by: | dlh |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.7.3 |
| Component: | Customize | Version: | 4.4 |
| Severity: | normal | Keywords: | has-patch has-unit-tests fixed-major |
| Cc: | Focuses: |
Description
Notice the else if statement
/* wp-includes/class-wp-customize-setting.php:533 */ protected function get_root_value( $default = null ) { $id_base = $this->id_data['base']; if ( 'option' === $this->type ) { return get_option( $id_base, $default ); } else if ( 'theme_mod' ) { return get_theme_mod( $id_base, $default ); } else { /* * Any WP_Customize_Setting subclass implementing aggregate multidimensional * will need to override this method to obtain the data from the appropriate * location. */ return $default; } }
Same bug applies to set_root_value
This can cause the Customizer to fail loading with the error
"sprintf(): Too few arguments"
On the sprintf function in get_theme_mod if $default is a string containing more than two % (percentage symbols)
Attachments (2)
Change History (15)
#1
follow-up:
↓ 2
@
10 years ago
- Milestone Awaiting Review
- Resolution → duplicate
- Status new → closed
- Version 4.5.2
This ticket was mentioned in Slack in #core-customize by dlh. View the logs.
9 years ago
#4
@
9 years ago
- Resolution duplicate
- Status closed → reopened
I might be misreading something, but it looks to me like @jontis is correct that this issue is not quite a duplicate of #34290. 36952.diff would update the two instances of if ( 'theme_mod' ) without comparisons to anything.
#6
@
9 years ago
@dlh would you be able to add unit tests to your patch to demonstrate the problem and the proven fix?
#9
@
9 years ago
- Keywords has-unit-tests added; needs-unit-tests removed
36952.2.diff amends the WP_Customize_Setting tests so that they trigger the bug in get_root_value().
Currently, core calls set_root_value() only in WP_Customize_Setting::update(), and even then, only after checking whether 'option' === $this->type || 'theme_mod' === $this->type. So, I think only a setting class with custom logic could trigger the set_root_value() bug. Let me know if you'd like me to add one to the tests.
#11
@
9 years ago
- Keywords fixed-major added
- Resolution fixed
- Status closed → reopened
Re-opening for 4.7.3
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hello @jontis, welcome to this Trac!
Thanks for your valid report. We're already tracking this issue in #34290.