Merge pull request #1804 from woocommerce/PCP-2104-warnings-on-php-8-1

Handle undefined array key warnings on PHP 8.1 (2104)
This commit is contained in:
Emili Castells 2023-11-03 10:55:14 +01:00 committed by GitHub
commit ad055d1e11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -48,8 +48,8 @@ class ApiModule implements ModuleInterface {
'ppcp_create_order_request_body_data', 'ppcp_create_order_request_body_data',
function( array $data ) use ( $c ) { function( array $data ) use ( $c ) {
foreach ( $data['purchase_units'] as $purchase_unit_index => $purchase_unit ) { foreach ( ( $data['purchase_units'] ?? array() ) as $purchase_unit_index => $purchase_unit ) {
foreach ( $purchase_unit['items'] as $item_index => $item ) { foreach ( ( $purchase_unit['items'] ?? array() ) as $item_index => $item ) {
$data['purchase_units'][ $purchase_unit_index ]['items'][ $item_index ]['name'] = $data['purchase_units'][ $purchase_unit_index ]['items'][ $item_index ]['name'] =
apply_filters( 'woocommerce_paypal_payments_cart_line_item_name', $item['name'], $item['cart_item_key'] ?? null ); apply_filters( 'woocommerce_paypal_payments_cart_line_item_name', $item['name'], $item['cart_item_key'] ?? null );
} }

View file

@ -102,7 +102,7 @@ class OrderTransient {
$transient = array(); $transient = array();
} }
if ( ! is_array( $transient['notes'] ) ) { if ( ! is_array( $transient['notes'] ?? null ) ) {
$transient['notes'] = array(); $transient['notes'] = array();
} }