Skip to content

Commit

Permalink
Move the call to the exists method to within the add_data method.
Browse files Browse the repository at this point in the history
  • Loading branch information
nefeline committed Apr 8, 2024
1 parent 00ad85a commit 1fcb81c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions plugins/woocommerce/src/Blocks/Assets/AssetDataRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,6 @@ public function add( $key, $data, $check_key_exists = false ) {
wc_deprecated_argument( 'Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry::add()', '8.9', 'The $check_key_exists parameter is no longer used: all duplicate data will be ignored if the key exists by default' );
}

if ( $this->exists( $key ) ) {
return;
}

$this->add_data( $key, $data );
}

Expand Down Expand Up @@ -416,6 +412,9 @@ protected function add_data( $key, $data ) {
trigger_error( esc_html__( 'Key for the data being registered must be a string', 'woocommerce' ), E_USER_WARNING );
return;
}
if ( $this->exists( $key ) ) {
return;
}
if ( isset( $this->data[ $key ] ) ) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
trigger_error( esc_html__( 'Overriding existing data with an already registered key is not allowed', 'woocommerce' ), E_USER_WARNING );
Expand Down

0 comments on commit 1fcb81c

Please sign in to comment.