Skip to content
This repository was archived by the owner on Mar 17, 2022. It is now read-only.

Commit 1d83ef2

Browse files
committed
improves #353 fix
additional defensive code ensures wc_product_generate_unique_sku doesn’t result in duplicate sku when called with no productid by woocommerce product_duplicate
1 parent 2a8f359 commit 1d83ef2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Hyyan/WPI/Product/Meta.php

+9
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,11 @@ public function suppressInvalidDuplicatedSKUErrorMsg($sku_found, $product_id, $s
820820
if ( ! $sku_found ) {
821821
return false;
822822
}
823+
//if called with no product id from woocommerce product_duplicate
824+
//no further check can be done
825+
if ( ! $product_id ) {
826+
return $sku_found;
827+
}
823828

824829
/*
825830
* now check the duplicates
@@ -842,6 +847,10 @@ public function suppressInvalidDuplicatedSKUErrorMsg($sku_found, $product_id, $s
842847
)
843848
);
844849
$curlang = pll_get_post_language( $product_id );
850+
if ( ! $curlang ) {
851+
//if there is no language no further check can be done
852+
return $sku_found;
853+
}
845854
foreach ( $postids as $post_id ) {
846855
//suppress duplicate sku error on translations only
847856
$duplang = pll_get_post_language( $post_id );

0 commit comments

Comments
 (0)