Make WordPress Core

Opened 9 years ago

Closed 8 years ago

#39184 closed defect (bug) (invalid)

Fatal error in child-theme customizer partials

Reported by: bastho's profile bastho Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: Customize Keywords: reporter-feedback
Focuses: Cc:

Description

When calling wp_customize::selective_refresh::add_partial without render_callback attribute, like this:

<?php
$wp_customize->selective_refresh->add_partial( 'setting_name', array(
 'selector' => '#object-id',
) );

No error is return, everything works well.
But, when a child theme is created, the customizer crashes with error:

Fatal error: Cannot unset string offsets in [...]/wp-includes/class-wp-customize-widgets.php on line 1077

Simply adding a dummy renderer as:

<?php
$wp_customize->selective_refresh->add_partial( 'setting_name', array(
 'selector' => '#object-id',
 'render_callback' => 'return_true',
) );

make it working every where.

Suggestions:

  1. Making the render_callback attribute mandatory
  2. Dealing with a default callback in child themes

Change History (4)

#1 @celloexpressions
9 years ago

  • Keywords needs-patch added

I think render_callback should probably be required, at least based on the current construction of partials. Not sure whether returning true there would work well, though. I never noticed that this was broken in child themes until recently.

It's hard to say what a default callback would look like. I was noticing a similar issue in child themes though.

#2 @westonruter
9 years ago

  • Keywords reporter-feedback added; needs-patch removed

@bastho I cannot reproduce the issue here. Note in your example also you have return_true as the render_callback but this is not defined and would cause a fatal error. I think you're looking for __return_true.

Here is a complete example showing a child theme of Twenty Seventeen that has two new partials for the title and tagline, the first lacks a render_callback while the second has it: https://gist.github.com/westonruter/cc0f17b18774c4d732778a27aeff232d

Please fork the child theme in that gist to bring it to a point where it exhibits the bug.

When I change the site title, the Ajax response returns with false as the rendered partial which is exactly as expected.

Also, the render_callback needn't be mandated because it can be supplied via the customize_partial_render filter or via overriding WP_Customize_Partial::render_callback() in a subclass.

This ticket was mentioned in Slack in #core-customize by celloexpressions. View the logs.


9 years ago

#4 @westonruter
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Closing due to lack of reporter feedback.

Note: See TracTickets for help on using tickets.