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

Update @wordpress packages for 6.3 RC2 #4892

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
428 changes: 214 additions & 214 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,30 @@
"@wordpress/api-fetch": "6.32.1",
"@wordpress/autop": "3.35.1",
"@wordpress/blob": "3.35.1",
"@wordpress/block-directory": "4.12.10",
"@wordpress/block-editor": "12.3.8",
"@wordpress/block-library": "8.12.10",
"@wordpress/block-directory": "4.12.11",
"@wordpress/block-editor": "12.3.9",
"@wordpress/block-library": "8.12.11",
"@wordpress/block-serialization-default-parser": "4.35.1",
"@wordpress/blocks": "12.12.4",
"@wordpress/blocks": "12.12.5",
"@wordpress/commands": "0.6.8",
"@wordpress/components": "25.1.8",
"@wordpress/compose": "6.12.1",
"@wordpress/core-commands": "0.4.8",
"@wordpress/core-data": "6.12.8",
"@wordpress/customize-widgets": "4.12.10",
"@wordpress/core-commands": "0.4.9",
"@wordpress/core-data": "6.12.9",
"@wordpress/customize-widgets": "4.12.11",
"@wordpress/data": "9.5.4",
"@wordpress/data-controls": "3.4.4",
"@wordpress/date": "4.35.1",
"@wordpress/deprecated": "3.35.1",
"@wordpress/dom": "3.35.1",
"@wordpress/dom-ready": "3.35.1",
"@wordpress/edit-post": "7.12.10",
"@wordpress/edit-site": "5.12.10",
"@wordpress/edit-widgets": "5.12.10",
"@wordpress/editor": "13.12.8",
"@wordpress/edit-post": "7.12.11",
"@wordpress/edit-site": "5.12.11",
"@wordpress/edit-widgets": "5.12.11",
"@wordpress/editor": "13.12.9",
"@wordpress/element": "5.12.1",
"@wordpress/escape-html": "2.35.1",
"@wordpress/format-library": "4.12.8",
"@wordpress/format-library": "4.12.9",
"@wordpress/hooks": "3.35.1",
"@wordpress/html-entities": "3.35.1",
"@wordpress/i18n": "4.35.1",
Expand All @@ -126,17 +126,17 @@
"@wordpress/priority-queue": "2.35.1",
"@wordpress/private-apis": "0.17.2",
"@wordpress/redux-routine": "4.35.1",
"@wordpress/reusable-blocks": "4.12.8",
"@wordpress/reusable-blocks": "4.12.9",
"@wordpress/rich-text": "6.12.5",
"@wordpress/router": "0.4.2",
"@wordpress/server-side-render": "4.12.8",
"@wordpress/server-side-render": "4.12.9",
"@wordpress/shortcode": "3.35.1",
"@wordpress/style-engine": "1.18.1",
"@wordpress/token-list": "2.35.1",
"@wordpress/url": "3.36.1",
"@wordpress/viewport": "5.12.4",
"@wordpress/warning": "2.35.1",
"@wordpress/widgets": "3.12.8",
"@wordpress/widgets": "3.12.9",
"@wordpress/wordcount": "3.35.1",
"backbone": "1.4.1",
"clipboard": "2.0.11",
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/assets/script-loader-packages.min.php

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/wp-includes/blocks/comment-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Function that recursively renders a list of nested comments.
*
* @since 6.3.0 Changed render_block_context priority to `1`.
*
* @global int $comment_depth
*
* @param WP_Comment[] $comments The array of comments.
Expand Down
138 changes: 138 additions & 0 deletions src/wp-includes/blocks/footnotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Renders the `core/footnotes` block on the server.
*
* @since 6.3.0
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
Expand Down Expand Up @@ -57,6 +59,8 @@ function render_block_core_footnotes( $attributes, $content, $block ) {

/**
* Registers the `core/footnotes` block on the server.
*
* @since 6.3.0
*/
function register_block_core_footnotes() {
foreach ( array( 'post', 'page' ) as $post_type ) {
Expand All @@ -78,3 +82,137 @@ function register_block_core_footnotes() {
);
}
add_action( 'init', 'register_block_core_footnotes' );

add_action(
'wp_after_insert_post',
/**
* Saves the footnotes meta value to the revision.
*
* @since 6.3.0
*
* @param int $revision_id The revision ID.
*/
static function( $revision_id ) {
$post_id = wp_is_post_revision( $revision_id );

if ( $post_id ) {
$footnotes = get_post_meta( $post_id, 'footnotes', true );

if ( $footnotes ) {
// Can't use update_post_meta() because it doesn't allow revisions.
update_metadata( 'post', $revision_id, 'footnotes', $footnotes );
}
}
}
);

add_action(
'_wp_put_post_revision',
/**
* Keeps track of the revision ID for "rest_after_insert_{$post_type}".
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's missing a since declaration here :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so anonymous functions should also receive @since?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these all anonymous functions in the first place?

Makes it impossible for developers to unhook them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally like anonymous functions for handling the footnote meta because it makes the way to move to handling postmeta revisions in a more standard way in 6.4.

Unless you think we'd still want the named functions after doing so?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would indeed be an argument for keeping them, but not sure if that's the reason for it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is a temporary fix and to avoid having to rename/naming clashes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this seem like an appropriate reason for using anonymous functions to you, @swissspidy ? (+cc: @peterwilsoncc and @joemcgill ).

If not, do you think we should continue discussion about this in the existing issue about revision support or open a new issue?

It sounded like there may be platform considerations for using named functions here, and I want to make sure those are well understood.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, yes

* @param int $revision_id The revision ID.
*/
static function( $revision_id ) {
global $_gutenberg_revision_id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the gutenberg prefix here. Is that okay?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also quite a hacky workaround in general having to use such a global here :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this is a temporary situation until revisions properly support post meta in core.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open for any better workarounds. It's quite late now to be adding general post meta revision support or start changing the REST API hook order.

$_gutenberg_revision_id = $revision_id;
}
);

foreach ( array( 'post', 'page' ) as $post_type ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this support all post types using the block editor and/or have revision support enabled?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this conversation / issue may be related:
WordPress/gutenberg#52812

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add_action(
"rest_after_insert_{$post_type}",
/**
* This is a specific fix for the REST API. The REST API doesn't update
* the post and post meta in one go (through `meta_input`). While it
* does fix the `wp_after_insert_post` hook to be called correctly after
* updating meta, it does NOT fix hooks such as post_updated and
* save_post, which are normally also fired after post meta is updated
* in `wp_insert_post()`. Unfortunately, `wp_save_post_revision` is
* added to the `post_updated` action, which means the meta is not
* available at the time, so we have to add it afterwards through the
* `"rest_after_insert_{$post_type}"` action.
*
* @since 6.3.0
*
* @param WP_Post $post The post object.
*/
static function( $post ) {
global $_gutenberg_revision_id;

if ( $_gutenberg_revision_id ) {
$revision = get_post( $_gutenberg_revision_id );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if we should use wp_get_post_revision here? It implements get_post, but has extra revision-specific checks that get_post doesn't.

Well, namely

	if ( 'revision' !== $revision->post_type ) {
		return null;
	}

😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$post_id = $revision->post_parent;

// Just making sure we're updating the right revision.
if ( $post->ID === $post_id ) {
$footnotes = get_post_meta( $post_id, 'footnotes', true );

if ( $footnotes ) {
// Can't use update_post_meta() because it doesn't allow revisions.
update_metadata( 'post', $_gutenberg_revision_id, 'footnotes', $footnotes );
}
}
}
}
);
}

add_action(
'wp_restore_post_revision',
/**
* Restores the footnotes meta value from the revision.
*
* @since 6.3.0
*
* @param int $post_id The post ID.
* @param int $revision_id The revision ID.
audrasjb marked this conversation as resolved.
Show resolved Hide resolved
*/
static function( $post_id, $revision_id ) {
$footnotes = get_post_meta( $revision_id, 'footnotes', true );

if ( $footnotes ) {
update_post_meta( $post_id, 'footnotes', $footnotes );
} else {
delete_post_meta( $post_id, 'footnotes' );
}
},
10,
2
);

add_filter(
'_wp_post_revision_fields',
/**
* Adds the footnotes field to the revision.
*
* @since 6.3.0
*
* @param array $fields The revision fields.
* @return array The revision fields.
*/
static function( $fields ) {
$fields['footnotes'] = __( 'Footnotes' );
return $fields;
}
);

add_filter(
'wp_post_revision_field_footnotes',
/**
* Gets the footnotes field from the revision.
*
* @since 6.3.0
*
* @param string $revision_field The field value, but $revision->$field
* (footnotes) does not exist.
* @param string $field The field name, in this case "footnotes".
* @param object $revision The revision object to compare against.
* @return string The field value.
*/
static function( $revision_field, $field, $revision ) {
return get_metadata( 'post', $revision->ID, $field, true );
},
10,
3
);
2 changes: 2 additions & 0 deletions src/wp-includes/blocks/pattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ function register_block_core_pattern() {
/**
* Renders the `core/pattern` block on the server.
*
* @since 6.3.0 Backwards compatibility: blocks with no `syncStatus` attribute do not receive block wrapper.
*
* @param array $attributes Block attributes.
*
* @return string Returns the output of the pattern.
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/blocks/post-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function block_core_post_template_uses_featured_image( $inner_blocks ) {
/**
* Renders the `core/post-template` block on the server.
*
* @since 6.3.0 Changed render_block_context priority to `1`.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/blocks/post-title.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Renders the `core/post-title` block on the server.
*
* @since 6.3.0 Omitting the $post argument from the `get_the_title`.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
Expand Down
2 changes: 2 additions & 0 deletions src/wp-includes/blocks/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Dynamically renders the `core/search` block.
*
* @since 6.3.0 Using block.json `viewScript` to register script, and update `view_script_handles()` only when needed.
*
* @param array $attributes The block attributes.
* @param string $content The saved content.
* @param WP_Block $block The parsed block.
Expand Down
Loading