|
26 | 26 | use Smartling\Helpers\FileUriHelper; |
27 | 27 | use Smartling\Helpers\GutenbergBlockHelper; |
28 | 28 | use Smartling\Helpers\LoggerSafeTrait; |
| 29 | +use Smartling\Helpers\MetaFieldProcessor\BulkProcessors\PostBasedProcessor; |
29 | 30 | use Smartling\Helpers\MetaFieldProcessor\DefaultMetaFieldProcessor; |
30 | 31 | use Smartling\Helpers\MetaFieldProcessor\MetaFieldProcessorAbstract; |
31 | 32 | use Smartling\Helpers\MetaFieldProcessor\MetaFieldProcessorManager; |
@@ -528,10 +529,9 @@ public function getRelations(string $contentType, int $id, array $targetBlogIds) |
528 | 529 | } |
529 | 530 | } |
530 | 531 |
|
531 | | - /** |
532 | | - * If processor is detected |
533 | | - */ |
534 | | - if ($processor instanceof MetaFieldProcessorAbstract && 0 !== (int)$fValue) { |
| 532 | + if ($processor instanceof PostBasedProcessor && is_array($this->wordpressProxy->maybe_unserialize($fValue))) { |
| 533 | + $detectedReferences[self::POST_BASED_PROCESSOR][] = $this->wordpressProxy->maybe_unserialize($fValue); |
| 534 | + } elseif ($processor instanceof MetaFieldProcessorAbstract && 0 !== (int)$fValue) { |
535 | 535 | $shortProcessorName = ArrayHelper::last(explode('\\', get_class($processor))); |
536 | 536 |
|
537 | 537 | $detectedReferences[$shortProcessorName][] = (int)$fValue; |
@@ -605,12 +605,21 @@ public function normalizeReferences(array $references): array |
605 | 605 | } |
606 | 606 |
|
607 | 607 | if (isset($references[self::POST_BASED_PROCESSOR])) { |
608 | | - foreach ($references[self::POST_BASED_PROCESSOR] as $postId) { |
609 | | - $postType = $this->wordpressProxy->get_post_type($postId); |
610 | | - if ($postType !== false) { |
611 | | - $result[$postType][] = $postId; |
612 | | - } else { |
613 | | - $this->getLogger()->warning("WordPress returned no post exist for detected reference postId=$postId"); |
| 608 | + foreach ($references[self::POST_BASED_PROCESSOR] as $reference) { |
| 609 | + if (!is_array($reference)) { |
| 610 | + $reference = [$reference]; |
| 611 | + } |
| 612 | + foreach ($reference as $referenceId) { |
| 613 | + if (!is_numeric($referenceId)) { |
| 614 | + $this->getLogger()->warning("Got non-numeric reference postId=$referenceId, skipping"); |
| 615 | + } |
| 616 | + $referenceId = (int)$referenceId; |
| 617 | + $postType = $this->wordpressProxy->get_post_type($referenceId); |
| 618 | + if ($postType !== false) { |
| 619 | + $result[$postType][] = $referenceId; |
| 620 | + } else { |
| 621 | + $this->getLogger()->warning("WordPress returned no post exists for detected reference postId=$referenceId, skipping"); |
| 622 | + } |
614 | 623 | } |
615 | 624 | } |
616 | 625 | } |
|
0 commit comments