diff --git a/lib/compat.php b/lib/compat.php index d4d223c42b760..ff0938c496828 100644 --- a/lib/compat.php +++ b/lib/compat.php @@ -134,7 +134,7 @@ function gutenberg_check_if_classic_needs_warning_about_blocks() { return; } - if ( ! has_blocks( $post ) && ! isset( $_REQUEST['cloudflare-error'] ) ) { + if ( ! has_blocks( $post ) ) { return; } @@ -142,11 +142,7 @@ function gutenberg_check_if_classic_needs_warning_about_blocks() { wp_enqueue_script( 'wp-a11y' ); wp_enqueue_script( 'wp-sanitize' ); - if ( isset( $_REQUEST['cloudflare-error'] ) ) { - add_action( 'admin_footer', 'gutenberg_warn_classic_about_cloudflare' ); - } else { - add_action( 'admin_footer', 'gutenberg_warn_classic_about_blocks' ); - } + add_action( 'admin_footer', 'gutenberg_warn_classic_about_blocks' ); } add_action( 'admin_enqueue_scripts', 'gutenberg_check_if_classic_needs_warning_about_blocks' ); @@ -308,150 +304,3 @@ function gutenberg_warn_classic_about_blocks() { - - -
-
-
-
-

-

-

-
    -
  • -
  • - change the REST API URL, to avoid triggering the WAF rules. Please be aware that this may cause issues with other plugins that use the REST API, and removes any other protection Cloudflare may be offering for the REST API.', 'gutenberg' ), - 'https://github.com/WordPress/gutenberg/issues/2704#issuecomment-410582252' - ); - ?> -
  • -
-

- follow this issue for updates. We hope to have this issue rectified soon!', 'gutenberg' ), - 'https://github.com/WordPress/gutenberg/issues/2704' - ); - ?> -

-
-

- -

-
-
- - - = 0 ) { - throw { - code: 'cloudflare_error', - }; - } -} - function apiFetch( options ) { const raw = ( nextOptions ) => { const { url, path, body, data, parse = true, ...remainingOptions } = nextOptions; @@ -82,18 +74,8 @@ function apiFetch( options ) { throw invalidJsonError; } - /* - * Response data is a stream, which will be consumed by the .json() call. - * If we need to re-use this data to send to the Cloudflare error handler, - * we need a clone of the original response, so the stream can be consumed - * in the .text() call, instead. - */ - const responseClone = response.clone(); - return response.json() - .catch( async () => { - const text = await responseClone.text(); - checkCloudflareError( text ); + .catch( () => { throw invalidJsonError; } ) .then( ( error ) => { @@ -102,8 +84,6 @@ function apiFetch( options ) { message: __( 'An unknown error occurred.' ), }; - checkCloudflareError( error ); - throw error || unknownError; } ); } ); diff --git a/packages/api-fetch/src/test/index.js b/packages/api-fetch/src/test/index.js index 220a618f17a3d..a01e0e7578159 100644 --- a/packages/api-fetch/src/test/index.js +++ b/packages/api-fetch/src/test/index.js @@ -32,9 +32,6 @@ describe( 'apiFetch', () => { message: 'Bad Request', } ); }, - clone() { - return null; - }, } ) ); return apiFetch( { path: '/random' } ).catch( ( body ) => { diff --git a/packages/editor/CHANGELOG.md b/packages/editor/CHANGELOG.md index 3b0ed28447c31..aefa03d7f5643 100644 --- a/packages/editor/CHANGELOG.md +++ b/packages/editor/CHANGELOG.md @@ -1,3 +1,5 @@ +## 6.1.1 (Unreleased) + ## 6.1.0 (2018-10-30) ### Deprecations diff --git a/packages/editor/src/store/effects/posts.js b/packages/editor/src/store/effects/posts.js index a7354ad101a58..6d6d23917c2bc 100644 --- a/packages/editor/src/store/effects/posts.js +++ b/packages/editor/src/store/effects/posts.js @@ -9,7 +9,6 @@ import { pick, includes } from 'lodash'; */ import apiFetch from '@wordpress/api-fetch'; import { __ } from '@wordpress/i18n'; -import { addQueryArgs } from '@wordpress/url'; // TODO: Ideally this would be the only dispatch in scope. This requires either // refactoring editor actions to yielded controls, or replacing direct dispatch // on the editor store with action creators (e.g. `REQUEST_POST_UPDATE_START`). @@ -266,25 +265,6 @@ export const requestPostUpdateFailure = ( action ) => { dataDispatch( 'core/notices' ).createErrorNotice( noticeMessage, { id: SAVE_POST_NOTICE_ID, } ); - - if ( error && 'cloudflare_error' === error.code ) { - dataDispatch( 'core/notices' ).createErrorNotice( - __( 'Cloudflare is blocking REST API requests.' ), - { - actions: [ - { - label: __( 'Learn More' ), - url: addQueryArgs( 'post.php', { - post: post.id, - action: 'edit', - 'classic-editor': '', - 'cloudflare-error': '', - } ), - }, - ], - }, - ); - } }; /**