[wp-trac] [WordPress Trac] #27355: Customizer: Add framework for selective refresh (partial preview refreshes)
WordPress Trac
noreply at wordpress.org
Thu Feb 18 19:31:30 UTC 2016
#27355: Customizer: Add framework for selective refresh (partial preview refreshes)
--------------------------------------+--------------------------
Reporter: westonruter | Owner: westonruter
Type: task (blessed) | Status: reviewing
Priority: normal | Milestone: 4.5
Component: Customize | Version: 3.4
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses: javascript
--------------------------------------+--------------------------
Comment (by westonruter):
Replying to [comment:72 ocean90]:
> * Nav Menus: When I enter "Foo<" into the input field for a menu item
title I get a PHP warning:
>
> {{{
> Object {partial: "nav_menu_instance[c306e5285ebf74fc00b87f1d9b839d2a]",
error_number: 8, error_string: "Uninitialized string offset: 1",
error_file: "/srv/www/wp-develop/svn/src/wp-includes/formatting.php",
error_line: 377} @ customize-selective-
refresh.js?ver=4.5-alpha-35776-src-1455794958:604
> Object {partial: "nav_menu_instance[c306e5285ebf74fc00b87f1d9b839d2a]",
error_number: 8, error_string: "Uninitialized string offset: 1",
error_file: "/srv/www/wp-develop/svn/src/wp-includes/formatting.php",
error_line: 377} @ customize-selective-
refresh.js?ver=4.5-alpha-35776-src-1455794958:604
> }}}
I grabbed a stack trace for when this error occurs and I found:
{{{
#0 /srv/www/wordpress-develop/src/wp-includes/formatting.php(377):
WP_Customize_Selective_Refresh->handle_error(8, 'Uninitialized s...',
'/srv/www/wordpr...', 377, Array)
#1 /srv/www/wordpress-develop/src/wp-includes/formatting.php(240):
_wptexturize_pushpop_element('<', Array, Array)
#2 [internal function]: wptexturize('Fosssos<')
#3 /srv/www/wordpress-develop/src/wp-includes/plugin.php(235):
call_user_func_array('wptexturize', Array)
#4 /srv/www/wordpress-develop/src/wp-includes/nav-menu-template.php(164):
apply_filters('the_title', 'Fosssos<', 4946)
#5 [internal function]: Walker_Nav_Menu->start_el('<li id="
;menu-it...', Object(WP_Post), 0, Object(stdClass))
#6 /srv/www/wordpress-develop/src/wp-includes/class-wp-walker.php(146):
call_user_func_array(Array, Array)
#7 /srv/www/wordpress-develop/src/wp-includes/class-wp-wa in <b>/srv/www
/wordpress-develop/src/wp-includes/customize/class-wp-customize-selective-
refresh.php</b> on line <b>283</b><br />
}}}
As such, it looks like it is specifically an issue with `wptexturize` and
not with selective refresh or nav menus in the customizer. If you save the
menu item and then exit the Customizer, you'll see the same PHP notice if
`WP_DEBUG_DISPLAY` is enabled. This patch fixes the issue:
{{{#!diff
--- src/wp-includes/formatting.php
+++ src/wp-includes/formatting.php
@@ -374,7 +374,7 @@ function wptexturize_primes( $haystack, $needle,
$prime, $open_quote, $close_quo
*/
function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements
) {
// Is it an opening tag or closing tag?
- if ( '/' !== $text[1] ) {
+ if ( isset( $text[1] ) && '/' !== $text[1] ) {
$opening_tag = true;
$name_offset = 1;
} elseif ( 0 == count( $stack ) ) {
}}}
> (Note: It seems like something is called twice on menu updates.)
@ocean90 Do you have the same menu appearing in multiple places, such as
assigned to a nav menu location ''and'' to a Custom Menu widget? If so,
then it is expected that the call to render would happen multiple times
since there would be multiple placements.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27355#comment:73>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list