-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blocks: skip null values returned from the server during registration #22849
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gziolo
added
[Type] Bug
An existing feature does not function as intended
[Feature] Block API
API that allows to express the block paradigm.
[Package] Blocks
/packages/blocks
labels
Jun 3, 2020
gziolo
requested review from
ellatrix,
TimothyBJacobs and
youknowriad
as code owners
June 3, 2020 06:15
Size Change: +25 B (0%) Total Size: 1.12 MB
ℹ️ View Unchanged
|
Changes required in WordPress core added here https://core.trac.wordpress.org/ticket/48529#comment:22: Index: src/wp-includes/class-wp-block-type.php
===================================================================
--- src/wp-includes/class-wp-block-type.php (revision 47891)
+++ src/wp-includes/class-wp-block-type.php (working copy)
@@ -32,9 +32,9 @@
/**
* @since 5.5.0
- * @var string
+ * @var string|null
*/
- public $category = '';
+ public $category = null;
/**
* @since 5.5.0
@@ -44,15 +44,15 @@
/**
* @since 5.5.0
- * @var string
+ * @var string|null
*/
- public $icon = '';
+ public $icon = null;
/**
* @since 5.5.0
@@ -104,25 +104,25 @@
* Block type editor script handle.
*
* @since 5.0.0
- * @var string
+ * @var string|null
*/
- public $editor_script = '';
+ public $editor_script = null;
/**
* Block type front end script handle.
*
* @since 5.0.0
- * @var string
+ * @var string|null
*/
- public $script = '';
+ public $script = null;
/**
* Block type editor style handle.
*
* @since 5.0.0
- * @var string
+ * @var string|null
*/
- public $editor_style = '';
+ public $editor_style = null;
/**
* Block type front end style handle.
@@ -130,7 +130,7 @@
* @since 5.0.0
* @var string
*/
- public $style = '';
+ public $style = null;
/**
* Constructor. |
aduth
approved these changes
Jun 3, 2020
nylen
pushed a commit
to nylen/wordpress-develop-svn
that referenced
this pull request
Jun 4, 2020
Related to the issue with default values for the blocks registered on the server. By using null for some fields we can treat them as undefined on the client. See: WordPress/gutenberg#22849. Props aduth. Fixes #48529. git-svn-id: https://develop.svn.wordpress.org/trunk@47907 602fd350-edb4-49c9-b593-d223f7449a82
pento
pushed a commit
to WordPress/wordpress-develop
that referenced
this pull request
Jun 4, 2020
Related to the issue with default values for the blocks registered on the server. By using null for some fields we can treat them as undefined on the client. See: WordPress/gutenberg#22849. Props aduth. Fixes #48529. git-svn-id: https://develop.svn.wordpress.org/trunk@47907 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith
pushed a commit
to markjaquith/WordPress
that referenced
this pull request
Jun 4, 2020
Related to the issue with default values for the blocks registered on the server. By using null for some fields we can treat them as undefined on the client. See: WordPress/gutenberg#22849. Props aduth. Fixes #48529. Built from https://develop.svn.wordpress.org/trunk@47907 git-svn-id: http://core.svn.wordpress.org/trunk@47681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
gMagicScott
pushed a commit
to gMagicScott/core.wordpress-mirror
that referenced
this pull request
Jun 4, 2020
Related to the issue with default values for the blocks registered on the server. By using null for some fields we can treat them as undefined on the client. See: WordPress/gutenberg#22849. Props aduth. Fixes #48529. Built from https://develop.svn.wordpress.org/trunk@47907 git-svn-id: https://core.svn.wordpress.org/trunk@47681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
gziolo
force-pushed
the
update/block-defaults-server
branch
from
June 4, 2020 06:14
8344e7d
to
e7f44db
Compare
oandregal
changed the title
Blocks: Skip null values returned from the server during registration
Blocks: skip null values returned from the server during registration
Jun 8, 2020
12 tasks
donmhico
pushed a commit
to donmhico/wordpress-develop
that referenced
this pull request
Jun 26, 2020
Related to the issue with default values for the blocks registered on the server. By using null for some fields we can treat them as undefined on the client. See: WordPress/gutenberg#22849. Props aduth. Fixes #48529. git-svn-id: https://develop.svn.wordpress.org/trunk@47907 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Feature] Block API
API that allows to express the block paradigm.
[Package] Blocks
/packages/blocks
[Type] Bug
An existing feature does not function as intended
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #22810.
This PR implements the approach discussed in #22810 and summarized by @aduth in #22810 (comment):
Summary
REST API fields that default now to
null
(all of them are optional) in addition to other fields covered earlier:description
icon
category
editor_script
script
editor_style
style
Added default values for two more settings in
registerBlockType
to align with REST API and the server implementation:supports
–{}
styles
–[]
Updated
registerBlockType
to skip fields withnull
andundefined
values passed from the server throughunstable__bootstrapServerSideBlockDefinitions
(that is eventually to be replaced with REST API endpoint).How has this been tested?
npm run test-unit
npm run test-php
Types of changes
Bug fix (non-breaking change which fixes an issue).
Checklist: