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

Revert: Templates perf: resolve patterns server side #61708

Closed
wants to merge 1 commit into from
Closed
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
107 changes: 0 additions & 107 deletions lib/compat/wordpress-6.6/resolve-patterns.php

This file was deleted.

1 change: 0 additions & 1 deletion lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ function gutenberg_is_experiment_enabled( $name ) {

// WordPress 6.6 compat.
require __DIR__ . '/compat/wordpress-6.6/compat.php';
require __DIR__ . '/compat/wordpress-6.6/resolve-patterns.php';
require __DIR__ . '/compat/wordpress-6.6/block-bindings/pattern-overrides.php';
require __DIR__ . '/compat/wordpress-6.6/block-template-utils.php';
require __DIR__ . '/compat/wordpress-6.6/option.php';
Expand Down
68 changes: 9 additions & 59 deletions test/e2e/specs/editor/plugins/pattern-recursion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,7 @@
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Preventing Pattern Recursion (client)', () => {
test.beforeEach( async ( { admin, editor, page } ) => {
await admin.createNewPost();
await editor.canvas
.locator( 'role=button[name="Add default block"i]' )
.click();
await page.evaluate( () => {
window.wp.data.dispatch( 'core/block-editor' ).updateSettings( {
__experimentalBlockPatterns: [
{
name: 'evil/recursive',
title: 'Evil recursive',
description: 'Evil recursive',
content:
'<!-- wp:paragraph --><p>Hello</p><!-- /wp:paragraph --><!-- wp:pattern {"slug":"evil/recursive"} /-->',
},
],
} );
} );
} );

test( 'prevents infinite loops due to recursive patterns', async ( {
editor,
} ) => {
await editor.insertBlock( {
name: 'core/pattern',
attributes: { slug: 'evil/recursive' },
} );
const warning = editor.canvas.getByText(
'Pattern "evil/recursive" cannot be rendered inside itself'
);
await expect( warning ).toBeVisible();
} );
} );

test.describe( 'Preventing Pattern Recursion (server)', () => {
test.describe( 'Preventing Pattern Recursion', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activatePlugin(
'gutenberg-test-protection-against-recursive-patterns'
Expand All @@ -56,30 +21,15 @@ test.describe( 'Preventing Pattern Recursion (server)', () => {
} );

test( 'prevents infinite loops due to recursive patterns', async ( {
page,
editor,
} ) => {
// Click the Toggle block inserter button
await page
.getByRole( 'button', { name: 'Toggle block inserter' } )
.click();
// Click the Patterns tab
await page.getByRole( 'tab', { name: 'Patterns' } ).click();
// Click the Uncategorized tab
await page.getByRole( 'tab', { name: 'Uncategorized' } ).click();
// Click the Evil recursive pattern
await page.getByRole( 'option', { name: 'Evil recursive' } ).click();
// By simply checking the editor content, we know that the pattern
// endpoint did not crash.
expect( await editor.getBlocks() ).toMatchObject( [
{
name: 'core/paragraph',
attributes: { content: 'Hello' },
},
{
name: 'core/paragraph',
attributes: { content: 'Hello' },
},
] );
await editor.insertBlock( {
name: 'core/pattern',
attributes: { slug: 'evil/recursive' },
} );
const warning = editor.canvas.getByText(
'Pattern "evil/recursive" cannot be rendered inside itself'
);
await expect( warning ).toBeVisible();
} );
} );
Loading