Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#45236 closed defect (bug) (fixed)

Cast the result of the `default_content`, `default_title`, and `default_excerpt` filters

Reported by: dd32's profile dd32 Owned by:
Milestone: 5.0 Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch commit fixed-5.0
Focuses: Cc:

Description

WordPress expects that the result of the default_* post filters are strings, but PHP isn't very strict about what an empty string is.

Gutenberg has run into an issue when the filters return null: https://github.com/WordPress/gutenberg/issues/11176

It seems reasonable to expect that the related values within the default $post object are strings (ref of where it's used)

Attached patch does just this, casting to a string to allow Gutenberg to receive the empty string that it expects in this case.

Attachments (1)

45236.diff (1.9 KB) - added by dd32 7 years ago.

Download all attachments as: .zip

Change History (6)

@dd32
7 years ago

#1 @danielbachhuber
7 years ago

  • Keywords has-patch commit added

Looks good to me.

#2 @pento
7 years ago

In 43858:

Editor: Cast the result of the default_content, default_title, and default_excerpt filters.

If a plugin returns a non-string value (or returns null) on these filters, it can cause errors in the block editor. Casting them as a string prevents these errors.

Props dd32.
See #45236.

#3 @pento
7 years ago

  • Keywords fixed-5.0 added

#4 @jeremyfelt
7 years ago

In 44224:

Editor: Cast the result of the default_content, default_title, and default_excerpt filters.

If a plugin returns a non-string value (or returns null) on these filters, it can cause errors in the block editor. Casting them as a string prevents these errors.

Merges [43858] from the 5.0 branch to trunk.

Props dd32.
See #45236.

#5 @SergeyBiryukov
7 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.