Skip to content

Commit

Permalink
prep build 2/6
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Feb 6, 2025
2 parents 699ced8 + e850c68 commit b6151e5
Show file tree
Hide file tree
Showing 39 changed files with 339 additions and 161 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/upload-release-to-plugin-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ jobs:
steps:
- name: Install Subversion
run: |
apt-get update -y && apt-get install -y subversion
sudo apt-get update -y && sudo apt-get install -y subversion
- name: Check out Gutenberg trunk from WP.org plugin repo
run: |
Expand Down Expand Up @@ -228,7 +228,7 @@ jobs:
steps:
- name: Install Subversion
run: |
apt-get update -y && apt-get install -y subversion
sudo apt-get update -y && sudo apt-get install -y subversion
- name: Download and unzip Gutenberg plugin asset into tags folder
env:
Expand Down
3 changes: 3 additions & 0 deletions backport-changelog/6.8/8228.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/8228

* https://github.com/WordPress/gutenberg/pull/68970
File renamed without changes.
12 changes: 11 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
== Changelog ==

= 20.2.0-rc.1 =
= 20.0.1 =

## Changelog

### Bug Fixes

- iAPI Router: add missing changelog entry for [#68923](https://github.com/WordPress/gutenberg/pull/68945)


= 20.2.0 =

## Changelog

Expand Down Expand Up @@ -143,6 +151,8 @@ The following contributors merged PRs in this release:
@afercia @benazeer-ben @fabiankaegy @himanshupathak95 @im3dabasia @Infinite-Null @justlevine @karthick-murugan @Mamaduka @Mayank-Tripathi32 @SainathPoojary @shail-mehta @shimotmk @Soean @spacedmonkey @stokesman @Sukhendu2002 @t-hamano @yogeshbhutkar




= 20.1.0 =

## Changelog
Expand Down
46 changes: 44 additions & 2 deletions lib/compat/wordpress-6.8/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ function gutenberg_add_default_template_part_areas_to_index( WP_REST_Response $r
$response->data['default_template_part_areas'] = get_allowed_block_template_part_areas();
return $response;
}

add_filter( 'rest_index', 'gutenberg_add_default_template_part_areas_to_index' );

/**
Expand All @@ -70,5 +69,48 @@ function gutenberg_add_default_template_types_to_index( WP_REST_Response $respon
$response->data['default_template_types'] = $indexed_template_types;
return $response;
}

add_filter( 'rest_index', 'gutenberg_add_default_template_types_to_index' );

/**
* Adds `ignore_sticky` parameter to the post collection endpoint.
*
* Note: Backports into the wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php file.
*
* @param array $query_params JSON Schema-formatted collection parameters.
* @param WP_Post_Type $post_type Post type object.
* @return array
*/
function gutenberg_modify_post_collection_paramt( $query_params, WP_Post_Type $post_type ) {
if ( 'post' === $post_type->name && ! isset( $query_params['ignore_sticky'] ) ) {
$query_params['ignore_sticky'] = array(
'description' => __( 'Whether to ignore sticky posts or not.' ),
'type' => 'boolean',
'default' => false,
);
}

return $query_params;
}
add_filter( 'rest_post_collection_params', 'gutenberg_modify_post_collection_paramt', 10, 2 );

/**
* Modify posts query based on `ignore_sticky` parameter.
*
* Note: Backports into the wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php file.
*
* @param array $prepared_args Array of arguments for WP_User_Query.
* @param WP_REST_Request $request The REST API request.
* @return array Modified arguments
*/
function gutenberg_modify_post_collection_query( $args, WP_REST_Request $request ) {
/*
* Honor the original REST API `post__in` behavior. Don't prepend sticky posts
* when `post__in` has been specified.
*/
if ( isset( $request['ignore_sticky'] ) && empty( $args['post__in'] ) ) {
$args['ignore_sticky_posts'] = $request['ignore_sticky'];
}

return $args;
}
add_filter( 'rest_post_query', 'gutenberg_modify_post_collection_query', 10, 2 );
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gutenberg",
"version": "20.2.0-rc.1",
"version": "20.2.0",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
43 changes: 34 additions & 9 deletions packages/api-fetch/src/middlewares/preloading.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,40 @@ function createPreloadingMiddleware( preloadedData ) {
* @return {Promise<any>} Promise with the response.
*/
function prepareResponse( responseData, parse ) {
return Promise.resolve(
parse
? responseData.body
: new window.Response( JSON.stringify( responseData.body ), {
status: 200,
statusText: 'OK',
headers: responseData.headers,
} )
);
if ( parse ) {
return Promise.resolve( responseData.body );
}

try {
return Promise.resolve(
new window.Response( JSON.stringify( responseData.body ), {
status: 200,
statusText: 'OK',
headers: responseData.headers,
} )
);
} catch {
// See: https://github.com/WordPress/gutenberg/issues/67358#issuecomment-2621163926.
Object.entries( responseData.headers ).forEach( ( [ key, value ] ) => {
if ( key.toLowerCase() === 'link' ) {
responseData.headers[ key ] = value.replace(
/<([^>]+)>/,
( /** @type {any} */ _, /** @type {string} */ url ) =>
`<${ encodeURI( url ) }>`
);
}
} );

return Promise.resolve(
parse
? responseData.body
: new window.Response( JSON.stringify( responseData.body ), {
status: 200,
statusText: 'OK',
headers: responseData.headers,
} )
);
}
}

export default createPreloadingMiddleware;
51 changes: 51 additions & 0 deletions packages/api-fetch/src/middlewares/test/preloading.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,57 @@ describe( 'Preloading Middleware', () => {
expect( secondMiddleware ).toHaveBeenCalledTimes( 1 );
} );

it( 'should not throw an error when non-ASCII headers are present', async () => {
const noResponseMock = 'undefined' === typeof window.Response;
if ( noResponseMock ) {
window.Response = class {
constructor( body, options ) {
this.body = JSON.parse( body );
this.headers = options.headers;

// Check for non-ASCII characters in headers
for ( const [ key, value ] of Object.entries(
this.headers || {}
) ) {
if ( /[^\x00-\x7F]/.test( value ) ) {
throw new Error(
`Invalid non-ASCII character found in header: ${ key }`
);
}
}
}
};
}

const data = {
body: 'Hello',
headers: {
Link: '<http://example.com/ویدیو/example>; rel="alternate"; type=text/html',
},
};

const preloadedData = {
'wp/v2/example': data,
};

const preloadingMiddleware =
createPreloadingMiddleware( preloadedData );

const requestOptions = {
method: 'GET',
path: 'wp/v2/example',
parse: false,
};

await expect(
preloadingMiddleware( requestOptions, () => {} )
).resolves.not.toThrow();

if ( noResponseMock ) {
delete window.Response;
}
} );

describe.each( [ [ 'GET' ], [ 'OPTIONS' ] ] )( '%s', ( method ) => {
describe.each( [
[ 'all empty', {} ],
Expand Down
2 changes: 1 addition & 1 deletion packages/block-directory/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/block-directory",
"version": "5.17.0",
"version": "5.17.1",
"description": "Extend editor with block directory features to search, download and install blocks.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
3 changes: 3 additions & 0 deletions packages/block-directory/src/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import InstalledBlocksPrePublishPanel from './installed-blocks-pre-publish-panel
import getInstallMissing from './get-install-missing';

registerPlugin( 'block-directory', {
// The icon is explicitly set to undefined to prevent PluginPrePublishPanel
// from rendering the fallback icon pluginIcon.
icon: undefined,
render() {
return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
import { _n, sprintf } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { blockDefault } from '@wordpress/icons';
import { PluginPrePublishPanel } from '@wordpress/editor';

/**
Expand All @@ -24,7 +23,6 @@ export default function InstalledBlocksPrePublishPanel() {

return (
<PluginPrePublishPanel
icon={ blockDefault }
title={ sprintf(
// translators: %d: number of blocks (number).
_n(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { store as blockEditorStore } from '../../store';

const SEARCH_THRESHOLD = 6;
const SHOWN_BLOCK_TYPES = 6;
const SHOWN_BLOCK_PATTERNS = 2;

export default function QuickInserter( {
onSelect,
Expand Down Expand Up @@ -106,7 +107,9 @@ export default function QuickInserter( {
rootClientId={ rootClientId }
clientId={ clientId }
isAppender={ isAppender }
maxBlockPatterns={ 0 }
maxBlockPatterns={
!! filterValue ? SHOWN_BLOCK_PATTERNS : 0
}
maxBlockTypes={ SHOWN_BLOCK_TYPES }
isDraggable={ false }
selectBlockOnInsert={ selectBlockOnInsert }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ function InserterSearchResults( {
] = useBlockTypesState( destinationRootClientId, onInsertBlocks, isQuick );
const [ patterns, , onClickPattern ] = usePatternsState(
onInsertBlocks,
destinationRootClientId
destinationRootClientId,
undefined,
isQuick
);

const filteredBlockPatterns = useMemo( () => {
Expand Down
4 changes: 0 additions & 4 deletions packages/block-editor/src/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ $block-inserter-tabs-height: 44px;
text-align: center;
}

.block-editor-inserter__no-results-icon {
fill: $gray-600;
}

.block-editor-inserter__child-blocks {
padding: 0 $grid-unit-20;
}
Expand Down
Loading

0 comments on commit b6151e5

Please sign in to comment.