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

Add backports for 5.7.1 RC #30517

Merged
merged 6 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 15 additions & 0 deletions lib/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,18 @@ function gutenberg_override_reusable_block_post_type_labels() {
);
}
add_filter( 'post_type_labels_wp_block', 'gutenberg_override_reusable_block_post_type_labels', 10, 0 );

/**
* Update allowed inline style attributes list.
*
* Note: This should be removed when the minimum required WP version is >= 5.8.
*
* @param string[] $attrs Array of allowed CSS attributes.
* @return string[] CSS attributes.
*/
function gutenberg_safe_style_attrs( $attrs ) {
$attrs[] = 'object-position';

return $attrs;
}
add_filter( 'safe_style_css', 'gutenberg_safe_style_attrs' );
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ function InsertionPointPopover( {
}
}

// Only show the inserter when there's a `nextElement` (a block after the
// insertion point). At the end of the block list the trailing appender
// should serve the purpose of inserting blocks.
const showInsertionPointInserter =
! isHidden && nextElement && ( isInserterShown || isInserterForced );

// Show the indicator if the insertion point inserter is visible, or if
// the `showInsertionPoint` state is `true`. The latter is generally true
// when hovering blocks for insertion in the block library.
const showInsertionPointIndicator =
showInsertionPointInserter || ( ! isHidden && showInsertionPoint );

/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
// While ideally it would be enough to capture the
// bubbling focus event from the Inserter, due to the
Expand All @@ -223,13 +235,10 @@ function InsertionPointPopover( {
className={ className }
style={ style }
>
{ ! isHidden &&
( showInsertionPoint ||
isInserterShown ||
isInserterForced ) && (
<div className="block-editor-block-list__insertion-point-indicator" />
) }
{ ! isHidden && ( isInserterShown || isInserterForced ) && (
{ showInsertionPointIndicator && (
<div className="block-editor-block-list__insertion-point-indicator" />
) }
{ showInsertionPointInserter && (
<InsertionPointInserter
rootClientId={ rootClientId }
clientId={ nextClientId }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function BlockTypesTab( {
);
} ) }

{ ! uncategorizedItems.length && (
{ uncategorizedItems.length > 0 && (
<InserterPanel
className="block-editor-inserter__uncategorized-blocks-panel"
title={ __( 'Uncategorized' ) }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/gallery/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ figure.wp-block-gallery {
bottom: 0;
left: 0;
z-index: 1;
pointer-events: none;
}
figcaption {
z-index: 2;
Expand Down
5 changes: 0 additions & 5 deletions packages/block-library/src/paragraph/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,3 @@ p.has-background {
p.has-text-color a {
color: inherit;
}

// Prevent an empty P tag from collapsing, so it matches the backend.
p:empty::before {
content: "\200B";
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
publishPost,
trashAllPosts,
activateTheme,
canvas,
} from '@wordpress/e2e-test-utils';

/**
Expand Down Expand Up @@ -193,9 +192,13 @@ describe( 'Multi-entity save flow', () => {
await navigationPanel.clickItemByText( 'Index' );
await navigationPanel.close();

// Click the first block so that the template part inserts in the right place.
const firstBlock = await canvas().$( '.wp-block' );
await firstBlock.click();
// Select the header template part via list view.
await page.click( 'button[aria-label="List View"]' );
const headerTemplatePartListViewButton = await page.waitForXPath(
'//button[contains(@class, "block-editor-block-navigation-block-select-button")][contains(., "Header")]'
);
headerTemplatePartListViewButton.click();
await page.click( 'button[aria-label="Close list view sidebar"]' );

// Insert something to dirty the editor.
await insertBlock( 'Paragraph' );
Expand Down
34 changes: 30 additions & 4 deletions packages/env/lib/build-docker-compose-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const path = require( 'path' );
* Internal dependencies
*/
const { hasSameCoreSource } = require( './wordpress' );
const { dbEnv } = require( './config' );

/**
* @typedef {import('./config').WPConfig} WPConfig
Expand Down Expand Up @@ -176,26 +177,40 @@ module.exports = function buildDockerComposeConfig( config ) {
image: 'mariadb',
ports: [ '3306' ],
environment: {
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes',
MYSQL_ROOT_PASSWORD:
dbEnv.credentials.WORDPRESS_DB_PASSWORD,
MYSQL_DATABASE: dbEnv.development.WORDPRESS_DB_NAME,
},
volumes: [ 'mysql:/var/lib/mysql' ],
},
'tests-mysql': {
image: 'mariadb',
ports: [ '3306' ],
environment: {
MYSQL_ROOT_PASSWORD:
dbEnv.credentials.WORDPRESS_DB_PASSWORD,
MYSQL_DATABASE: dbEnv.tests.WORDPRESS_DB_NAME,
},
volumes: [ 'mysql-test:/var/lib/mysql' ],
},
wordpress: {
build: '.',
depends_on: [ 'mysql' ],
image: developmentWpImage,
ports: [ developmentPorts ],
environment: {
WORDPRESS_DB_NAME: 'wordpress',
...dbEnv.credentials,
...dbEnv.development,
},
volumes: developmentMounts,
},
'tests-wordpress': {
depends_on: [ 'mysql' ],
depends_on: [ 'tests-mysql' ],
image: testsWpImage,
ports: [ testsPorts ],
environment: {
WORDPRESS_DB_NAME: 'tests-wordpress',
...dbEnv.credentials,
...dbEnv.tests,
},
volumes: testsMounts,
},
Expand All @@ -204,12 +219,20 @@ module.exports = function buildDockerComposeConfig( config ) {
image: developmentWpCliImage,
volumes: developmentMounts,
user: cliUser,
environment: {
...dbEnv.credentials,
...dbEnv.development,
},
},
'tests-cli': {
depends_on: [ 'tests-wordpress' ],
image: testsWpCliImage,
volumes: testsMounts,
user: cliUser,
environment: {
...dbEnv.credentials,
...dbEnv.tests,
},
},
composer: {
image: 'composer',
Expand All @@ -228,13 +251,16 @@ module.exports = function buildDockerComposeConfig( config ) {
LOCAL_DIR: 'html',
WP_PHPUNIT__TESTS_CONFIG:
'/var/www/html/phpunit-wp-config.php',
...dbEnv.credentials,
...dbEnv.tests,
},
},
},
volumes: {
...( ! config.coreSource && { wordpress: {} } ),
...( ! config.coreSource && { 'tests-wordpress': {} } ),
mysql: {},
'mysql-test': {},
'phpunit-uploads': {},
},
};
Expand Down
6 changes: 6 additions & 0 deletions packages/env/lib/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const downloadSources = require( '../download-sources' );
const {
checkDatabaseConnection,
makeContentDirectoriesWritable,
makeConfigWritable,
configureWordPress,
setupWordPressDirectories,
} = require( '../wordpress' );
Expand Down Expand Up @@ -140,6 +141,11 @@ module.exports = async function start( { spinner, debug, update, xdebug } ) {
: [],
} );

await Promise.all( [
makeConfigWritable( 'development', config ),
makeConfigWritable( 'tests', config ),
] );

// Only run WordPress install/configuration when config has changed.
if ( shouldConfigureWp ) {
spinner.text = 'Configuring WordPress.';
Expand Down
23 changes: 23 additions & 0 deletions packages/env/lib/config/db-env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Username and password used in all databases
const credentials = {
WORDPRESS_DB_USER: 'root',
WORDPRESS_DB_PASSWORD: 'password',
};

// Environment for test database
const tests = {
WORDPRESS_DB_NAME: 'tests-wordpress',
WORDPRESS_DB_HOST: 'tests-mysql',
};

// Environment for development database. DB host gets default value which is set
// elsewhere
const development = {
WORDPRESS_DB_NAME: 'wordpress',
};

module.exports = {
credentials,
tests,
development,
};
2 changes: 2 additions & 0 deletions packages/env/lib/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
const readConfig = require( './config' );
const { ValidationError } = require( './validate-config' );
const dbEnv = require( './db-env' );

/**
* @typedef {import('./config').WPConfig} WPConfig
Expand All @@ -13,4 +14,5 @@ const { ValidationError } = require( './validate-config' );
module.exports = {
ValidationError,
readConfig,
dbEnv,
};
22 changes: 22 additions & 0 deletions packages/env/lib/wordpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,27 @@ async function makeContentDirectoriesWritable(
);
}

/**
* Makes wp-config.php owned by www-data so that WordPress can work with the
* file.
*
* @param {WPEnvironment} environment The environment to check. Either 'development' or 'tests'.
* @param {WPConfig} config The wp-env config object.
*/
async function makeConfigWritable(
environment,
{ dockerComposeConfigPath, debug }
) {
await dockerCompose.exec(
environment === 'development' ? 'wordpress' : 'tests-wordpress',
'chown www-data:www-data wp-config.php',
{
config: dockerComposeConfigPath,
log: debug,
}
);
}

/**
* Checks a WordPress database connection. An error is thrown if the test is
* unsuccessful.
Expand Down Expand Up @@ -260,6 +281,7 @@ async function copyCoreFiles( fromPath, toPath ) {
module.exports = {
hasSameCoreSource,
makeContentDirectoriesWritable,
makeConfigWritable,
checkDatabaseConnection,
configureWordPress,
resetDatabase,
Expand Down