Block Editor: Update packages with latest fixes for 5.8 RC2

Includes the following fixes:

- Query Block: Type validation of `WP_Query` parameters.

Props ntsekouras, stevehenty, peterwilsoncc, desrosj.
Merges [51362] to the 5.8 branch.
Fixes #53397.


Built from https://develop.svn.wordpress.org/branches/5.8@51363


git-svn-id: http://core.svn.wordpress.org/branches/5.8@50972 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2021-07-07 00:06:17 +00:00
parent dae3e79ad8
commit 051e04b3cc
6 changed files with 69 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@ -1047,8 +1047,11 @@ function build_query_vars_from_query_block( $block, $page ) {
);
if ( isset( $block->context['query'] ) ) {
if ( isset( $block->context['query']['postType'] ) ) {
$query['post_type'] = $block->context['query']['postType'];
if ( ! empty( $block->context['query']['postType'] ) ) {
$post_type_param = $block->context['query']['postType'];
if ( is_post_type_viewable( $post_type_param ) ) {
$query['post_type'] = $post_type_param;
}
}
if ( isset( $block->context['query']['sticky'] ) && ! empty( $block->context['query']['sticky'] ) ) {
$sticky = get_option( 'sticky_posts' );
@ -1058,29 +1061,54 @@ function build_query_vars_from_query_block( $block, $page ) {
$query['post__not_in'] = array_merge( $query['post__not_in'], $sticky );
}
}
if ( isset( $block->context['query']['exclude'] ) ) {
$query['post__not_in'] = array_merge( $query['post__not_in'], $block->context['query']['exclude'] );
if ( ! empty( $block->context['query']['exclude'] ) ) {
$excluded_post_ids = array_map( 'intval', $block->context['query']['exclude'] );
$excluded_post_ids = array_filter( $excluded_post_ids );
$query['post__not_in'] = array_merge( $query['post__not_in'], $excluded_post_ids );
}
if ( isset( $block->context['query']['perPage'] ) ) {
$query['offset'] = ( $block->context['query']['perPage'] * ( $page - 1 ) ) + $block->context['query']['offset'];
$query['posts_per_page'] = $block->context['query']['perPage'];
if (
isset( $block->context['query']['perPage'] ) &&
is_numeric( $block->context['query']['perPage'] )
) {
$per_page = absint( $block->context['query']['perPage'] );
$offset = 0;
if (
isset( $block->context['query']['offset'] ) &&
is_numeric( $block->context['query']['offset'] )
) {
$offset = absint( $block->context['query']['offset'] );
}
if ( isset( $block->context['query']['categoryIds'] ) ) {
$query['category__in'] = $block->context['query']['categoryIds'];
$query['offset'] = ( $per_page * ( $page - 1 ) ) + $offset;
$query['posts_per_page'] = $per_page;
}
if ( isset( $block->context['query']['tagIds'] ) ) {
$query['tag__in'] = $block->context['query']['tagIds'];
if ( ! empty( $block->context['query']['categoryIds'] ) ) {
$term_ids = array_map( 'intval', $block->context['query']['categoryIds'] );
$term_ids = array_filter( $term_ids );
$query['category__in'] = $term_ids;
}
if ( isset( $block->context['query']['order'] ) ) {
if ( ! empty( $block->context['query']['tagIds'] ) ) {
$term_ids = array_map( 'intval', $block->context['query']['tagIds'] );
$term_ids = array_filter( $term_ids );
$query['tag__in'] = $term_ids;
}
if (
isset( $block->context['query']['order'] ) &&
in_array( strtoupper( $block->context['query']['order'] ), array( 'ASC', 'DESC' ), true )
) {
$query['order'] = strtoupper( $block->context['query']['order'] );
}
if ( isset( $block->context['query']['orderBy'] ) ) {
$query['orderby'] = $block->context['query']['orderBy'];
}
if ( isset( $block->context['query']['author'] ) ) {
$query['author'] = $block->context['query']['author'];
if (
isset( $block->context['query']['author'] ) &&
(int) $block->context['query']['author'] > 0
) {
$query['author'] = (int) $block->context['query']['author'];
}
if ( isset( $block->context['query']['search'] ) ) {
if ( ! empty( $block->context['query']['search'] ) ) {
$query['s'] = $block->context['query']['search'];
}
}

View File

@ -18,6 +18,10 @@ function render_block_core_post_terms( $attributes, $content, $block ) {
return '';
}
if ( ! is_taxonomy_viewable( $attributes['term'] ) ) {
return '';
}
$post_terms = get_the_terms( $block->context['postId'], $attributes['term'] );
if ( is_wp_error( $post_terms ) ) {
return '';

View File

@ -31487,12 +31487,26 @@ function usePostTerms({
postType,
term
}) {
var _term$visibility2;
const {
rest_base: restBase,
slug
} = term;
const [termIds] = Object(external_wp_coreData_["useEntityProp"])('postType', postType, restBase, postId);
return Object(external_wp_data_["useSelect"])(select => {
var _term$visibility;
const visible = term === null || term === void 0 ? void 0 : (_term$visibility = term.visibility) === null || _term$visibility === void 0 ? void 0 : _term$visibility.publicly_queryable;
if (!visible) {
return {
postTerms: [],
_isLoading: false,
hasPostTerms: false
};
}
if (!termIds) {
// Waiting for post terms to be fetched.
return {
@ -31523,7 +31537,7 @@ function usePostTerms({
isLoading: _isLoading,
hasPostTerms: !!(terms !== null && terms !== void 0 && terms.length)
};
}, [termIds]);
}, [termIds, term === null || term === void 0 ? void 0 : (_term$visibility2 = term.visibility) === null || _term$visibility2 === void 0 ? void 0 : _term$visibility2.publicly_queryable]);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-library/build-module/post-terms/edit.js
@ -31570,7 +31584,7 @@ function PostTermsEdit({
getTaxonomy
} = select(external_wp_coreData_["store"]);
const taxonomy = getTaxonomy(term);
return taxonomy !== null && taxonomy !== void 0 && (_taxonomy$visibility = taxonomy.visibility) !== null && _taxonomy$visibility !== void 0 && _taxonomy$visibility.show_ui ? taxonomy : {};
return taxonomy !== null && taxonomy !== void 0 && (_taxonomy$visibility = taxonomy.visibility) !== null && _taxonomy$visibility !== void 0 && _taxonomy$visibility.publicly_queryable ? taxonomy : {};
}, [term]);
const {
postTerms,

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.8-RC1-51361';
$wp_version = '5.8-RC1-51363';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.