Skip to content
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

Block Bindings: Send only edited values to the POST API requrest #64714

Closed
2 tasks done
cbravobernal opened this issue Aug 22, 2024 · 3 comments
Closed
2 tasks done

Block Bindings: Send only edited values to the POST API requrest #64714

cbravobernal opened this issue Aug 22, 2024 · 3 comments
Assignees
Labels

Comments

@cbravobernal
Copy link
Contributor

cbravobernal commented Aug 22, 2024

Description

Since 6.6, you can now edit the values of binded custom fields in the editor. If you do that, you send all the default values to de REST API. Fortunately, those values are not saved in DB.

Screenshot of what is being sent when I only edited the pokemon_typeto "Water Type"
Screenshot 2024-08-22 at 13 18 00

The rest of the fields are not connected in any block of the post.

Removing this from the fields can save some bytes sent to the server, meta fields can grow exponentially with plugins installed.

Step-by-step reproduction instructions

  1. Register your meta.
register_meta(
		'post',
		'pokemon_attack',
		array(
			'show_in_rest'      => true,
			'single'            => true,
			'type'              => 'string',
			'default'           => 'Scratch',
			'object_subtype' => 'page',
		)
	);
	register_meta(
		'post',
		'pokemon_type',
		array(
			'show_in_rest'      => true,
			'single'            => true,
			'type'              => 'string',
			'default'           => 'Plant',
		)
	);
  1. Create a post. Enable block bindings UI experiment. Connect a paragraph to any field created. Edit the field.
  2. Save and the API request.
  3. Check that the DB only contains the meta data updated, not the API request.

Environment info

  • WordPress trunk, latest Gutenberg version.

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes
@cbravobernal cbravobernal added the [Type] Bug An existing feature does not function as intended label Aug 22, 2024
@cbravobernal cbravobernal self-assigned this Aug 22, 2024
@gziolo
Copy link
Member

gziolo commented Aug 22, 2024

Since 6.6, you can now edit the values of binded custom fields in the editor. If you do that, you send all the default values to de REST API. Fortunately, those values are not saved in DB.

Removing this from the fields can save some bytes sent to the server, meta fields can grow exponentially with plugins installed.

Can you clarify what the issue needs to be solved here? The screenshot included shows the legacy meta boxes panel enabled, so it isn't clear if that applies to that interface or to the Save functionality triggered after changes were applied through the connected block attribute. If I follow correctly, everything works as intended, but the amount of the data sent could be reduced by skipping non-modified meta values, right?

@cbravobernal
Copy link
Contributor Author

cbravobernal commented Aug 22, 2024

Sorry if it was not clear.

The legacy meta boxes panel in this case does not apply. Is only the save functionality after editing a connected field.
Yes, everything works, but, as you mention, we can reduce the data sent doing what you mention.

@cbravobernal cbravobernal changed the title Block Bindings: Editing values is sending all default ones to the rest API. Block Bindings: Editing values is sending all custom meta to the rest API, even if they have not been modified. Aug 22, 2024
@cbravobernal cbravobernal added [Type] Enhancement A suggestion for improvement. and removed [Type] Bug An existing feature does not function as intended labels Aug 22, 2024
@cbravobernal cbravobernal changed the title Block Bindings: Editing values is sending all custom meta to the rest API, even if they have not been modified. Block Bindings: Send only edited values to the POST API requrest Aug 22, 2024
@cbravobernal
Copy link
Contributor Author

Closing this ticket until new considerations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants