Skip to content

Commit

Permalink
prep build 6/6
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Jun 6, 2024
2 parents 397642d + 9d8420f commit 822ce1e
Show file tree
Hide file tree
Showing 51 changed files with 710 additions and 214 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php-changes-detection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Get changed PHP files
id: changed-files-php
uses: tj-actions/changed-files@03334d095e2739fa9ac4034ec16f66d5d01e9eba # v44.5.1
uses: tj-actions/changed-files@d6babd6899969df1a11d14c368283ea4436bca78 # v44.5.2
with:
files: |
lib/**
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rnmobile-ios-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- uses: ruby/setup-ruby@943103cae7d3f1bb1e4951d5fcc7928b40e4b742 # v1.177.1
- uses: ruby/setup-ruby@d5fb7a202fc07872cb44f00ba8e6197b70cb0c55 # v1.179.0
with:
# `.ruby-version` file location
working-directory: packages/react-native-editor/ios
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ jobs:
# dependency versions are installed and cached.
##
- name: Set up PHP
uses: shivammathur/setup-php@c665c7a15b5295c2488ac8a87af9cb806cd72198 # v2.30.4
uses: shivammathur/setup-php@fc14643b0a99ee9db10a3c025a33d76544fa3761 # v2.30.5
with:
php-version: '${{ matrix.php }}'
ini-file: development
Expand Down Expand Up @@ -286,7 +286,7 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Set up PHP
uses: shivammathur/setup-php@c665c7a15b5295c2488ac8a87af9cb806cd72198 # v2.30.4
uses: shivammathur/setup-php@fc14643b0a99ee9db10a3c025a33d76544fa3761 # v2.30.5
with:
php-version: '7.4'
coverage: none
Expand Down
3 changes: 3 additions & 0 deletions backport-changelog/6.6/6737.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/6737

* https://github.com/WordPress/gutenberg/pull/62305
9 changes: 7 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
== Changelog ==

= 18.5.0-rc.1 =

= 18.5.0 =

## Changelog

Expand Down Expand Up @@ -111,6 +110,7 @@
- Lock binding editing with functions. ([61734](https://github.com/WordPress/gutenberg/pull/61734))

#### Block Variations
- Detect active variation correctly based on RichText attribute. ([62325](https://github.com/WordPress/gutenberg/pull/62325))
- Have `getActiveBlockVariation` return variation with highest specificity. ([62031](https://github.com/WordPress/gutenberg/pull/62031))
- Support dot notation in `isActive` string array. ([62088](https://github.com/WordPress/gutenberg/pull/62088))

Expand All @@ -137,6 +137,8 @@

### Bug Fixes

- Editor: Only render the site logo once if there's a fill. ([62320](https://github.com/WordPress/gutenberg/pull/62320))
- Interactivity API: Increase directive `wp-each-child` priority. ([62293](https://github.com/WordPress/gutenberg/pull/62293))w
- Compose: Fix 'useFocusOnMount' cleanup callback. ([62053](https://github.com/WordPress/gutenberg/pull/62053))
- Do not auto save post status changes. ([62171](https://github.com/WordPress/gutenberg/pull/62171))
- Editor: Fix canvas padding in post editor. ([61893](https://github.com/WordPress/gutenberg/pull/61893))
Expand Down Expand Up @@ -167,6 +169,7 @@
- Post Actions: Hide the trash action for auto-drafts. ([61865](https://github.com/WordPress/gutenberg/pull/61865))

#### Block Editor
- Inserter: Update Openverse API URLs. ([62241](https://github.com/WordPress/gutenberg/pull/62241))
- Fix being unable to switch modes while inserter is open. ([61563](https://github.com/WordPress/gutenberg/pull/61563))
- Fix editor inserter tabs indicator. ([61973](https://github.com/WordPress/gutenberg/pull/61973))
- Fix positioning of close icons in panels to be consistent. ([61832](https://github.com/WordPress/gutenberg/pull/61832))
Expand Down Expand Up @@ -467,6 +470,8 @@ The following contributors merged PRs in this release:
@aaronrobertshaw @abhi3315 @afercia @ajlende @akashdhawade2005 @akasunil @Aljullu @amitraj2203 @andrewserong @anton-vlasenko @anver @artemiomorales @carolinan @cbravobernal @colorful-tones @creativecoder @DaniGuardiola @DAreRodz @dbrian @draganescu @ellatrix @fabiankaegy @fullofcaffeine @gemkev @geriux @glendaviesnz @gziolo @jameskoster @jasmussen @jeryj @jorgefilipecosta @jsnajdr @kellenmace @kevin940726 @kt-12 @madhusudhand @Mamaduka @mattsherman @mcsf @michalczaplinski @mirka @narenin @nateinaction @ndiego @ntsekouras @oandregal @ockham @paolopiaggio @ramonjd @retrofox @richtabor @sanjucta @SantosGuillamot @scruffian @senadir @shail-mehta @sirreal @stokesman @t-hamano @talldan @taylorgorman @tellthemachines @tjcafferkey @twstokes @tyxla @vcanales @vipul0425 @westonruter @WunderBart @youknowriad




= 18.4.1 =

## Changelog
Expand Down
16 changes: 11 additions & 5 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -734,14 +734,14 @@ public static function get_element_class_name( $element ) {
*
* @param array $theme_json A structure that follows the theme.json schema.
* @param string $origin Optional. What source of data this object represents.
* One of 'default', 'theme', or 'custom'. Default 'theme'.
* One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'.
*/
public function __construct( $theme_json = array( 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA ), $origin = 'theme' ) {
if ( ! in_array( $origin, static::VALID_ORIGINS, true ) ) {
$origin = 'theme';
}

$this->theme_json = WP_Theme_JSON_Schema_Gutenberg::migrate( $theme_json );
$this->theme_json = WP_Theme_JSON_Schema_Gutenberg::migrate( $theme_json, $origin );
$registry = WP_Block_Type_Registry::get_instance();
$valid_block_names = array_keys( $registry->get_all_registered() );
$valid_element_names = array_keys( static::ELEMENTS );
Expand Down Expand Up @@ -3278,15 +3278,21 @@ protected static function filter_slugs( $node, $slugs ) {
* Removes insecure data from theme.json.
*
* @since 5.9.0
* @since 6.6.0 Added support for block style variation element styles.
* @since 6.6.0 Added support for block style variation element styles and $origin parameter.
*
* @param array $theme_json Structure to sanitize.
* @param string $origin Optional. What source of data this object represents.
* One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'.
* @return array Sanitized structure.
*/
public static function remove_insecure_properties( $theme_json ) {
public static function remove_insecure_properties( $theme_json, $origin = 'theme' ) {
if ( ! in_array( $origin, static::VALID_ORIGINS, true ) ) {
$origin = 'theme';
}

$sanitized = array();

$theme_json = WP_Theme_JSON_Schema_Gutenberg::migrate( $theme_json );
$theme_json = WP_Theme_JSON_Schema_Gutenberg::migrate( $theme_json, $origin );

$valid_block_names = array_keys( static::get_blocks_metadata() );
$valid_element_names = array_keys( static::ELEMENTS );
Expand Down
10 changes: 3 additions & 7 deletions lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,18 +534,14 @@ public static function get_user_data() {
isset( $decoded_data['isGlobalStylesUserThemeJSON'] ) &&
$decoded_data['isGlobalStylesUserThemeJSON']
) {
unset( $decoded_data['isGlobalStylesUserThemeJSON'] );
$config = $decoded_data;
}
}

/** This filter is documented in wp-includes/class-wp-theme-json-resolver.php */
$theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data_Gutenberg( $config, 'custom' ) );
$config = $theme_json->get_data();

// Needs to be set for schema migrations of user data.
$config['isGlobalStylesUserThemeJSON'] = true;

static::$user = new WP_Theme_JSON_Gutenberg( $config, 'custom' );
$theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data_Gutenberg( $config, 'custom' ) );
static::$user = $theme_json->get_theme_json();

return static::$user;
}
Expand Down
20 changes: 10 additions & 10 deletions lib/class-wp-theme-json-schema-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ class WP_Theme_JSON_Schema_Gutenberg {
* @since 5.9.0
* @since 6.6.0 Migrate up to v3.
*
* @param array $theme_json The structure to migrate.
* @param array $theme_json The structure to migrate.
* @param string $origin Optional. What source of data this object represents.
* One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'.
*
* @return array The structure in the last version.
*/
public static function migrate( $theme_json ) {
public static function migrate( $theme_json, $origin = 'theme' ) {
if ( ! isset( $theme_json['version'] ) ) {
$theme_json = array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
Expand All @@ -57,7 +59,7 @@ public static function migrate( $theme_json ) {
$theme_json = self::migrate_v1_to_v2( $theme_json );
// Deliberate fall through. Once migrated to v2, also migrate to v3.
case 2:
$theme_json = self::migrate_v2_to_v3( $theme_json );
$theme_json = self::migrate_v2_to_v3( $theme_json, $origin );
}

return $theme_json;
Expand Down Expand Up @@ -103,11 +105,12 @@ private static function migrate_v1_to_v2( $old ) {
*
* @since 6.6.0
*
* @param array $old Data to migrate.
*
* @param array $old Data to migrate.
* @param string $origin What source of data this object represents.
* One of 'blocks', 'default', 'theme', or 'custom'.
* @return array Data with defaultFontSizes set to false.
*/
private static function migrate_v2_to_v3( $old ) {
private static function migrate_v2_to_v3( $old, $origin ) {
// Copy everything.
$new = $old;

Expand All @@ -118,10 +121,7 @@ private static function migrate_v2_to_v3( $old ) {
* Remaining changes do not need to be applied to the custom origin,
* as they should take on the value of the theme origin.
*/
if (
isset( $new['isGlobalStylesUserThemeJSON'] ) &&
true === $new['isGlobalStylesUserThemeJSON']
) {
if ( 'custom' === $origin ) {
return $new;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/experimental/kses.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function gutenberg_filter_global_styles_post( $data ) {
) {
unset( $decoded_data['isGlobalStylesUserThemeJSON'] );

$data_to_encode = WP_Theme_JSON_Gutenberg::remove_insecure_properties( $decoded_data );
$data_to_encode = WP_Theme_JSON_Gutenberg::remove_insecure_properties( $decoded_data, 'custom' );

$data_to_encode['isGlobalStylesUserThemeJSON'] = true;
return wp_slash( wp_json_encode( $data_to_encode ) );
Expand Down
10 changes: 5 additions & 5 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": "18.5.0-rc.1",
"version": "18.5.0",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
8 changes: 6 additions & 2 deletions packages/block-library/src/missing/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ export class UnsupportedBlockEdit extends Component {
canEditUnsupportedBlock() {
const {
canEnableUnsupportedBlockEditor,
isEditableInUnsupportedBlockEditor,
isUnsupportedBlockEditorSupported,
} = this.props;

return (
! canEnableUnsupportedBlockEditor &&
isUnsupportedBlockEditorSupported
isUnsupportedBlockEditorSupported &&
isEditableInUnsupportedBlockEditor
);
}

Expand Down Expand Up @@ -194,7 +196,8 @@ export class UnsupportedBlockEdit extends Component {

render() {
const { originalName } = this.props.attributes;
const { getStylesFromColorScheme, preferredColorScheme } = this.props;
const { isSelected, getStylesFromColorScheme, preferredColorScheme } =
this.props;
const blockType = coreBlocks[ originalName ];

const title = this.getTitle();
Expand Down Expand Up @@ -226,6 +229,7 @@ export class UnsupportedBlockEdit extends Component {
const iconClassName = 'unsupported-icon' + '-' + preferredColorScheme;
return (
<TouchableOpacity
disabled={ ! isSelected }
activeOpacity={ 0.5 }
accessibilityLabel={ __( 'Help button' ) }
accessibilityRole="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`Missing block renders without crashing 1`] = `
{
"busy": undefined,
"checked": undefined,
"disabled": undefined,
"disabled": true,
"expanded": undefined,
"selected": undefined,
}
Expand Down
41 changes: 22 additions & 19 deletions packages/blocks/src/api/parser/fix-custom-classname.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,30 @@ export function getHTMLRootElementClasses( innerHTML ) {
* @return {Object} Filtered block attributes.
*/
export function fixCustomClassname( blockAttributes, blockType, innerHTML ) {
if ( hasBlockSupport( blockType, 'customClassName', true ) ) {
// To determine difference, serialize block given the known set of
// attributes, with the exception of `className`. This will determine
// the default set of classes. From there, any difference in innerHTML
// can be considered as custom classes.
const { className: omittedClassName, ...attributesSansClassName } =
blockAttributes;
const serialized = getSaveContent( blockType, attributesSansClassName );
const defaultClasses = getHTMLRootElementClasses( serialized );
const actualClasses = getHTMLRootElementClasses( innerHTML );
if ( ! hasBlockSupport( blockType, 'customClassName', true ) ) {
return blockAttributes;
}

const modifiedBlockAttributes = { ...blockAttributes };
// To determine difference, serialize block given the known set of
// attributes, with the exception of `className`. This will determine
// the default set of classes. From there, any difference in innerHTML
// can be considered as custom classes.
const { className: omittedClassName, ...attributesSansClassName } =
modifiedBlockAttributes;
const serialized = getSaveContent( blockType, attributesSansClassName );
const defaultClasses = getHTMLRootElementClasses( serialized );
const actualClasses = getHTMLRootElementClasses( innerHTML );

const customClasses = actualClasses.filter(
( className ) => ! defaultClasses.includes( className )
);
const customClasses = actualClasses.filter(
( className ) => ! defaultClasses.includes( className )
);

if ( customClasses.length ) {
blockAttributes.className = customClasses.join( ' ' );
} else if ( serialized ) {
delete blockAttributes.className;
}
if ( customClasses.length ) {
modifiedBlockAttributes.className = customClasses.join( ' ' );
} else if ( serialized ) {
delete modifiedBlockAttributes.className;
}

return blockAttributes;
return modifiedBlockAttributes;
}
2 changes: 1 addition & 1 deletion packages/blocks/src/api/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function applyBlockValidation( unvalidatedBlock, blockType ) {
);
// Attempt to validate the block once again after the built-in fixes.
const [ isFixedValid, validationIssues ] = validateBlock(
unvalidatedBlock,
fixedBlock,
blockType
);

Expand Down
32 changes: 32 additions & 0 deletions packages/blocks/src/api/parser/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,38 @@ describe( 'block parser', () => {
} );

describe( 'parseRawBlock', () => {
it( 'should apply className block validation fixes', () => {
registerBlockType( 'core/test-block', {
...defaultBlockSettings,
attributes: {
fruit: {
type: 'string',
source: 'text',
selector: 'div',
},
},
save: ( { attributes } ) => (
// eslint-disable-next-line react/no-unknown-property
<div class={ attributes.className }>
{ attributes.fruit }
</div>
),
} );

const block = parseRawBlock( {
blockName: 'core/test-block',
innerHTML:
'<div class="custom-class another-custom-class">Bananas</div>',
attrs: { fruit: 'Bananas' },
} );

expect( block.name ).toEqual( 'core/test-block' );
expect( block.attributes ).toEqual( {
fruit: 'Bananas',
className: 'custom-class another-custom-class',
} );
} );

it( 'should create the requested block if it exists', () => {
registerBlockType( 'core/test-block', defaultBlockSettings );

Expand Down
Loading

0 comments on commit 822ce1e

Please sign in to comment.