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.
Fixes #53397.


Built from https://develop.svn.wordpress.org/trunk@51362


git-svn-id: http://core.svn.wordpress.org/trunk@50971 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2021-07-06 23:57:21 +00:00
parent 39ff1d6709
commit d73dcb8378
6 changed files with 69 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@ -1057,8 +1057,11 @@ function build_query_vars_from_query_block( $block, $page ) {
); );
if ( isset( $block->context['query'] ) ) { if ( isset( $block->context['query'] ) ) {
if ( isset( $block->context['query']['postType'] ) ) { if ( ! empty( $block->context['query']['postType'] ) ) {
$query['post_type'] = $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'] ) ) { if ( isset( $block->context['query']['sticky'] ) && ! empty( $block->context['query']['sticky'] ) ) {
$sticky = get_option( 'sticky_posts' ); $sticky = get_option( 'sticky_posts' );
@ -1068,29 +1071,54 @@ function build_query_vars_from_query_block( $block, $page ) {
$query['post__not_in'] = array_merge( $query['post__not_in'], $sticky ); $query['post__not_in'] = array_merge( $query['post__not_in'], $sticky );
} }
} }
if ( isset( $block->context['query']['exclude'] ) ) { if ( ! empty( $block->context['query']['exclude'] ) ) {
$query['post__not_in'] = array_merge( $query['post__not_in'], $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'] ) ) { if (
$query['offset'] = ( $block->context['query']['perPage'] * ( $page - 1 ) ) + $block->context['query']['offset']; isset( $block->context['query']['perPage'] ) &&
$query['posts_per_page'] = $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'] );
}
$query['offset'] = ( $per_page * ( $page - 1 ) ) + $offset;
$query['posts_per_page'] = $per_page;
} }
if ( isset( $block->context['query']['categoryIds'] ) ) { if ( ! empty( $block->context['query']['categoryIds'] ) ) {
$query['category__in'] = $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']['tagIds'] ) ) { if ( ! empty( $block->context['query']['tagIds'] ) ) {
$query['tag__in'] = $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'] ) ) { if (
isset( $block->context['query']['order'] ) &&
in_array( strtoupper( $block->context['query']['order'] ), array( 'ASC', 'DESC' ), true )
) {
$query['order'] = strtoupper( $block->context['query']['order'] ); $query['order'] = strtoupper( $block->context['query']['order'] );
} }
if ( isset( $block->context['query']['orderBy'] ) ) { if ( isset( $block->context['query']['orderBy'] ) ) {
$query['orderby'] = $block->context['query']['orderBy']; $query['orderby'] = $block->context['query']['orderBy'];
} }
if ( isset( $block->context['query']['author'] ) ) { if (
$query['author'] = $block->context['query']['author']; 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']; $query['s'] = $block->context['query']['search'];
} }
} }

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.9-alpha-51359'; $wp_version = '5.9-alpha-51362';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.