| @@ -6,9 +6,8 @@ | ||
| 6 | 6 | use Templately\Builder\Factory\TemplateFactory; |
| 7 | 7 | use Templately\Core\Importer\FullSiteImport; |
| 8 | 8 | use Templately\Core\Importer\Import; |
| 9 | 9 | use Templately\Core\Importer\LogHelper; |
| 10 | -use Templately\Core\Importer\Utils\AIUtils; | |
| 11 | 10 | use Templately\Core\Importer\Utils\ImportHelper; |
| 12 | 11 | use Templately\Core\Importer\Utils\Utils; |
| 13 | 12 | |
| 14 | 13 | abstract class BaseRunner { |
| @@ -61,14 +60,9 @@ | ||
| 61 | 60 | $this->factory = new TemplateFactory( $this->platform ); |
| 62 | 61 | $this->json = Utils::get_json_helper( $this->platform ); |
| 63 | 62 | $this->json->session_id = $this->session_id; |
| 64 | 63 | |
| 65 | - // Normalize once here so every runner sees the canonical | |
| 66 | - // `type/sub_type => ['id',...]` shape. This value arrives from the import | |
| 67 | - // FormData (a JSON string), session data, or the manifest, and consumers | |
| 68 | - // index into it in ways that either throw or silently miss pages when the | |
| 69 | - // shape differs. See AIUtils::normalize_ai_page_ids(). | |
| 70 | - $this->ai_page_ids = AIUtils::normalize_ai_page_ids( $request_params['ai_page_ids'] ?? [] ); | |
| 64 | + $this->ai_page_ids = $request_params['ai_page_ids'] ?? []; | |
| 71 | 65 | $this->process_id = $request_params['process_id'] ?? null; |
| 72 | 66 | |
| 73 | 67 | if ( empty( $this->platform ) ) { |
| 74 | 68 | throw new Exception( __( 'Platform is not specified. Please try again after specifying the platform.', 'templately' ) ); |
| @@ -119,14 +113,18 @@ | ||
| 119 | 113 | throw new Exception($message); |
| 120 | 114 | } |
| 121 | 115 | |
| 122 | 116 | protected function is_ai_content($old_template_id ): bool { |
| 123 | - if(empty($this->process_id) || empty($this->ai_page_ids)){ | |
| 117 | + if(empty($this->process_id) || empty($this->ai_page_ids) || !is_array($this->ai_page_ids)){ | |
| 124 | 118 | return false; |
| 125 | 119 | } |
| 120 | + // Get array of AI page IDs, filtering out any non-numeric values | |
| 121 | + $ai_page_ids = array_reduce($this->ai_page_ids, 'array_merge', array()); | |
| 122 | + // $ai_page_ids = array_filter( | |
| 123 | + // array_map('intval', explode(',', $this->ai_page_ids ?? '')) | |
| 124 | + // ); | |
| 126 | 125 | |
| 127 | - // $this->ai_page_ids is already normalized in the constructor, so this is | |
| 128 | - // a plain flatten + strict membership test. It used to array_reduce with | |
| 129 | - // 'array_merge', which throws a TypeError if any group value is a scalar. | |
| 130 | - return AIUtils::is_ai_content($old_template_id, $this->ai_page_ids); | |
| 126 | + $is_ai_content = in_array($old_template_id, $ai_page_ids); | |
| 127 | + | |
| 128 | + return $is_ai_content; | |
| 131 | 129 | } |
| 132 | 130 | } |