Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Release: 7.2.1 (#6072)
Browse files Browse the repository at this point in the history
* Empty commit for release pull request

* Create deprecated_dependency wrapper to log errors conditionally (#6074)

Store Editing  E2E tests are failing because of an upstream regression, not related to this PR

* add readme

* add testing steps

* Bumping version strings to new version.

* Bumping version strings to new version.

* Bumping version strings to new version.

Co-authored-by: github-actions <[email protected]>
Co-authored-by: Mike Jolley <[email protected]>
Co-authored-by: Nadir Seghir <[email protected]>
  • Loading branch information
4 people authored Mar 23, 2022
1 parent b64bffc commit 59f074a
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 8 deletions.
13 changes: 13 additions & 0 deletions docs/testing/releases/721.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Testing notes and ZIP for release 7.2.1

Zip file for testing: [woocommerce-gutenberg-products-block.zip](https://github.com/woocommerce/woocommerce-gutenberg-products-block/files/8333094/woocommerce-gutenberg-products-block.zip)

## Feature plugin and package inclusion in WooCommerce

### Hide deprecation notices before headers are sent. [#6074](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/6074)

1. Enable WooCommerce Payments or WooCommerce Subscriptions. It hasn't been updated with compatibility yet (I put in a PR a week ago).
2. Enable WP_DEBUG mode
3. Go to WP Admin. No notices are visible.
4. Check the error log. See the notices there.
5. Edit the code in this PR and remove the 7.4 from the function calls. Repeat steps 2-4 and confirm logs are used.
1 change: 1 addition & 0 deletions docs/testing/releases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Every release includes specific testing instructions for new features and bug fi
- [7.0.0](./700.md)
- [7.1.0](./710.md)
- [7.2.0](./720.md)
- [7.2.1](./721.md)

<!-- FEEDBACK -->

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@woocommerce/block-library",
"title": "WooCommerce Blocks",
"author": "Automattic",
"version": "7.2.0",
"version": "7.2.1",
"description": "WooCommerce blocks for the Gutenberg editor.",
"homepage": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/",
"keywords": [
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: gutenberg, woocommerce, woo commerce, products, blocks, woocommerce blocks
Requires at least: 5.9
Tested up to: 5.9
Requires PHP: 7.0
Stable tag: 7.2.0
Stable tag: 7.2.1
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -85,6 +85,11 @@ Release and roadmap notes available on the [WooCommerce Developers Blog](https:/

== Changelog ==

= 7.2.1 - 2022-03-23 =

#### Bug fixes

- Don't trigger class deprecations if headers are already sent [#6074](https://github.com/woocommerce/woocommerce-gutenberg-products-block/pull/6074)
= 7.2.0 - 2022-03-14 =

#### Bug Fixes
Expand Down
61 changes: 57 additions & 4 deletions src/Domain/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,33 +264,86 @@ function () {
$this->container->register(
'Automattic\WooCommerce\Blocks\StoreApi\Formatters',
function( Container $container ) {
_deprecated_function( 'Automattic\WooCommerce\Blocks\StoreApi\Formatters', '7.2.0', 'Automattic\WooCommerce\StoreApi\Formatters' );
$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\Formatters', '7.2.0', 'Automattic\WooCommerce\StoreApi\Formatters', '7.4.0' );
return $container->get( StoreApi::class )::container()->get( \Automattic\WooCommerce\StoreApi\Formatters::class );
}
);
$this->container->register(
'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi',
function( Container $container ) {
_deprecated_function( 'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi', '7.2.0', 'Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema' );
$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi', '7.2.0', 'Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema', '7.4.0' );
return $container->get( StoreApi::class )::container()->get( \Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema::class );
}
);
$this->container->register(
'Automattic\WooCommerce\Blocks\StoreApi\SchemaController',
function( Container $container ) {
_deprecated_function( 'Automattic\WooCommerce\Blocks\StoreApi\SchemaController', '7.2.0', 'Automattic\WooCommerce\StoreApi\SchemaController' );
$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\SchemaController', '7.2.0', 'Automattic\WooCommerce\StoreApi\SchemaController', '7.4.0' );
return $container->get( StoreApi::class )::container()->get( SchemaController::class );
}
);
$this->container->register(
'Automattic\WooCommerce\Blocks\StoreApi\RoutesController',
function( Container $container ) {
_deprecated_function( 'Automattic\WooCommerce\Blocks\StoreApi\RoutesController', '7.2.0', 'Automattic\WooCommerce\StoreApi\RoutesController' );
$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\RoutesController', '7.2.0', 'Automattic\WooCommerce\StoreApi\RoutesController', '7.4.0' );
return $container->get( StoreApi::class )::container()->get( RoutesController::class );
}
);
}

/**
* Throws a deprecation notice for a dependency without breaking requests.
*
* @param string $function Class or function being deprecated.
* @param string $version Version in which it was deprecated.
* @param string $replacement Replacement class or function, if applicable.
* @param string $trigger_error_version Optional version to start surfacing this as a PHP error rather than a log. Defaults to $version.
*/
protected function deprecated_dependency( $function, $version, $replacement = '', $trigger_error_version = '' ) {
if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
return;
}

$trigger_error_version = $trigger_error_version ? $trigger_error_version : $version;
$error_message = $replacement ? sprintf(
'%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
$function,
$version,
$replacement
) : sprintf(
'%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.',
$function,
$version
);

do_action( 'deprecated_function_run', $function, $replacement, $version );

$log_error = false;

// If headers have not been sent yet, log to avoid breaking the request.
if ( ! headers_sent() ) {
$log_error = true;
}

// If the $trigger_error_version was not yet reached, only log the error.
if ( version_compare( $this->package->get_version(), $trigger_error_version, '<' ) ) {
$log_error = true;
}

// Apply same filter as WP core.
if ( ! apply_filters( 'deprecated_function_trigger_error', true ) ) {
$log_error = true;
}

if ( $log_error ) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
error_log( $error_message );
} else {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
trigger_error( $error_message, E_USER_DEPRECATED );
}
}

/**
* Register payment method integrations with the container.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static function container( $reset = false ) {
NewPackage::class,
function ( $container ) {
// leave for automated version bumping.
$version = '7.2.0';
$version = '7.2.1';
return new NewPackage(
$version,
dirname( __DIR__ ),
Expand Down
2 changes: 1 addition & 1 deletion woocommerce-gutenberg-products-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WooCommerce Blocks
* Plugin URI: https://github.com/woocommerce/woocommerce-gutenberg-products-block
* Description: WooCommerce blocks for the Gutenberg editor.
* Version: 7.2.0
* Version: 7.2.1
* Author: Automattic
* Author URI: https://woocommerce.com
* Text Domain: woo-gutenberg-products-block
Expand Down

0 comments on commit 59f074a

Please sign in to comment.