@@ -318,34 +318,7 @@ protected function process()
318
318
try {
319
319
$ this ->urlRewriteId = $ this ->persistUrlRewrite ($ urlRewrite );
320
320
} catch (\PDOException $ pdoe ) {
321
- $ message = sprintf (
322
- 'Is a PDO exception is thrown: with Urlrewrite Data \\n
323
- ("entity_id": "%s" && "request_path": "%s" && "target_path": "%s" && "entity_type": "%s" && "redirect_type": "%s" && "store_id": "%s") ' ,
324
- $ urlRewriteProductCategory [MemberNames::ENTITY_ID ],
325
- $ urlRewriteProductCategory [MemberNames::REQUEST_PATH ],
326
- $ urlRewriteProductCategory [MemberNames::TARGET_PATH ],
327
- $ urlRewriteProductCategory [MemberNames::ENTITY_TYPE ],
328
- $ urlRewriteProductCategory [MemberNames::REDIRECT_TYPE ],
329
- $ urlRewriteProductCategory [MemberNames::STORE_ID ]
330
- );
331
- if (!$ this ->getSubject ()->isStrictMode ()) {
332
- $ this ->getSubject ()
333
- ->getSystemLogger ()
334
- ->warning ($ this ->getSubject ()->appendExceptionSuffix ($ message ));
335
- $ this ->mergeStatus (
336
- array (
337
- RegistryKeys::NO_STRICT_VALIDATIONS => array (
338
- basename ($ this ->getFilename ()) => array (
339
- $ this ->getLineNumber () => array (
340
- ColumnKeys::URL_KEY => $ message
341
- )
342
- )
343
- )
344
- )
345
- );
346
- } else {
347
- throw new \PDOException ($ pdoe );
348
- }
321
+ $ this ->handleDuplicateUrlKeyExceptionWithStrictMode ($ urlRewrite , $ pdoe );
349
322
}
350
323
} else {
351
324
$ this ->urlRewriteId = $ urlRewrite [MemberNames::URL_REWRITE_ID ];
@@ -369,34 +342,7 @@ protected function process()
369
342
try {
370
343
$ this ->persistUrlRewriteProductCategory ($ urlRewriteProductCategory );
371
344
} catch (\PDOException $ pdoe ) {
372
- $ message = sprintf (
373
- 'Is a PDO exception is thrown: with Urlrewrite Data \\n
374
- ("entity_id": "%s" && "request_path": "%s" && "target_path": "%s" && "entity_type": "%s" && "redirect_type": "%s" && "store_id": "%s") ' ,
375
- $ urlRewriteProductCategory [MemberNames::ENTITY_ID ],
376
- $ urlRewriteProductCategory [MemberNames::REQUEST_PATH ],
377
- $ urlRewriteProductCategory [MemberNames::TARGET_PATH ],
378
- $ urlRewriteProductCategory [MemberNames::ENTITY_TYPE ],
379
- $ urlRewriteProductCategory [MemberNames::REDIRECT_TYPE ],
380
- $ urlRewriteProductCategory [MemberNames::STORE_ID ]
381
- );
382
- if (!$ this ->getSubject ()->isStrictMode ()) {
383
- $ this ->getSubject ()
384
- ->getSystemLogger ()
385
- ->warning ($ this ->getSubject ()->appendExceptionSuffix ($ message ));
386
- $ this ->mergeStatus (
387
- array (
388
- RegistryKeys::NO_STRICT_VALIDATIONS => array (
389
- basename ($ this ->getFilename ()) => array (
390
- $ this ->getLineNumber () => array (
391
- ColumnKeys::URL_KEY => $ message
392
- )
393
- )
394
- )
395
- )
396
- );
397
- } else {
398
- throw new \PDOException ($ pdoe );
399
- }
345
+ $ this ->handleDuplicateUrlKeyExceptionWithStrictMode ($ urlRewriteProductCategory , $ pdoe );
400
346
}
401
347
}
402
348
} catch (\Exception $ e ) {
@@ -921,4 +867,42 @@ protected function loadProduct($sku)
921
867
{
922
868
return $ this ->getProductUrlRewriteProcessor ()->loadProduct ($ sku );
923
869
}
870
+
871
+ /**
872
+ * @param array $urlRewriteData
873
+ * @param \PDOException|\Exception $pdoe
874
+ * @return void
875
+ * @throws \Exception
876
+ */
877
+ public function handleDuplicateUrlKeyExceptionWithStrictMode (array $ urlRewriteData , \PDOException |\Exception $ pdoe ): void
878
+ {
879
+ $ message = sprintf (
880
+ 'Is a "Duplicate entry" PDO exception is thrown: with Urlrewrite Data \\n
881
+ ("entity_id": "%s" && "request_path": "%s" && "target_path": "%s" && "entity_type": "%s" && "redirect_type": "%s" && "store_id": "%s") ' ,
882
+ $ urlRewriteData [MemberNames::ENTITY_ID ],
883
+ $ urlRewriteData [MemberNames::REQUEST_PATH ],
884
+ $ urlRewriteData [MemberNames::TARGET_PATH ],
885
+ $ urlRewriteData [MemberNames::ENTITY_TYPE ],
886
+ $ urlRewriteData [MemberNames::REDIRECT_TYPE ],
887
+ $ urlRewriteData [MemberNames::STORE_ID ]
888
+ );
889
+ if (!$ this ->getSubject ()->isStrictMode ()) {
890
+ $ this ->getSubject ()
891
+ ->getSystemLogger ()
892
+ ->warning ($ this ->getSubject ()->appendExceptionSuffix ($ message ));
893
+ $ this ->mergeStatus (
894
+ array (
895
+ RegistryKeys::NO_STRICT_VALIDATIONS => array (
896
+ basename ($ this ->getFilename ()) => array (
897
+ $ this ->getLineNumber () => array (
898
+ ColumnKeys::URL_KEY => $ message
899
+ )
900
+ )
901
+ )
902
+ )
903
+ );
904
+ } else {
905
+ throw new \PDOException ($ pdoe );
906
+ }
907
+ }
924
908
}
0 commit comments