← All changes
|
app/modules/import-export/processes/import.php
+5
-25
4.3.0-beta3
→
3.32.0-dev3
View file →
| @@ -7,10 +7,8 @@ | ||
| 7 | 7 | use Elementor\App\Modules\ImportExport\Compatibility\Kit_Library; |
| 8 | 8 | use Elementor\App\Modules\ImportExport\Utils; |
| 9 | 9 | use Elementor\Core\Base\Document; |
| 10 | 10 | use Elementor\Core\Kits\Documents\Kit; |
| 11 | -use Elementor\Modules\AtomicWidgets\Utils\Atomic_Prop_Remap; | |
| 12 | -use Elementor\Modules\Components\Module as Components_Module; | |
| 13 | 11 | use Elementor\Plugin; |
| 14 | 12 | |
| 15 | 13 | use Elementor\App\Modules\ImportExport\Runners\Import\Elementor_Content; |
| 16 | 14 | use Elementor\App\Modules\ImportExport\Runners\Import\Import_Runner_Base; |
| @@ -140,14 +138,13 @@ | ||
| 140 | 138 | */ |
| 141 | 139 | private $runners_import_metadata = []; |
| 142 | 140 | |
| 143 | 141 | /** |
| 144 | - * @param string $path session_id | zip_file_path | |
| 145 | - * @param array $settings Use to determine which content to import. | |
| 146 | - * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.) | |
| 142 | + * @param string $path session_id | zip_file_path | |
| 143 | + * @param array $settings Use to determine which content to import. | |
| 144 | + * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.) | |
| 147 | 145 | * @param array|null $old_instance An array of old instance parameters that will be used for creating new instance. |
| 148 | - * We are using it for quick creation of the instance when the import process is being split into chunks. | |
| 149 | - * | |
| 146 | + * We are using it for quick creation of the instance when the import process is being split into chunks. | |
| 150 | 147 | * @throws \Exception If the import session does not exist. |
| 151 | 148 | */ |
| 152 | 149 | public function __construct( string $path, array $settings = [], array $old_instance = null ) { |
| 153 | 150 | if ( ! empty( $old_instance ) ) { |
| @@ -561,9 +558,9 @@ | ||
| 561 | 558 | |
| 562 | 559 | /** |
| 563 | 560 | * Prevent saving elements on elementor post creation. |
| 564 | 561 | * |
| 565 | - * @param array $data | |
| 562 | + * @param array $data | |
| 566 | 563 | * @param Document $document |
| 567 | 564 | * |
| 568 | 565 | * @return array |
| 569 | 566 | */ |
| @@ -586,9 +583,8 @@ | ||
| 586 | 583 | * Extract the zip file. |
| 587 | 584 | * |
| 588 | 585 | * @param string $zip_path The path to the zip file. |
| 589 | 586 | * @return string The extracted directory path. |
| 590 | - * @throws \Error If import process fails, file validation errors occur, or data corruption is detected. | |
| 591 | 587 | */ |
| 592 | 588 | private function extract_zip( $zip_path ) { |
| 593 | 589 | $extraction_result = Plugin::$instance->uploads_manager->extract_and_validate_zip( $zip_path, [ 'json', 'xml' ] ); |
| 594 | 590 | |
| @@ -606,10 +602,8 @@ | ||
| 606 | 602 | /** |
| 607 | 603 | * Get the manifest file from the extracted directory and adapt it if needed. |
| 608 | 604 | * |
| 609 | 605 | * @return string The manifest file content. |
| 610 | - * | |
| 611 | - * @throws \Error If import validation fails or processing errors occur. | |
| 612 | 606 | */ |
| 613 | 607 | private function read_manifest_json() { |
| 614 | 608 | $manifest = Utils::read_json_file( $this->extracted_directory_path . 'manifest' ); |
| 615 | 609 | |
| @@ -741,11 +735,8 @@ | ||
| 741 | 735 | foreach ( $this->documents_data as $new_id => $data ) { |
| 742 | 736 | $document = Plugin::$instance->documents->get( $new_id ); |
| 743 | 737 | |
| 744 | 738 | if ( isset( $data['elements'] ) ) { |
| 745 | - $data['elements'] = Components_Module::prepare_imported_elements( $data['elements'], $imported_data_replacements['post_ids'] ?? [] ); | |
| 746 | - $data['elements'] = Atomic_Prop_Remap::apply( $data['elements'], $imported_data_replacements ); | |
| 747 | - $this->merge_atomic_prop_remap_warnings( Atomic_Prop_Remap::consume_warnings() ); | |
| 748 | 739 | $data['elements'] = $document->on_import_update_dynamic_content( $data['elements'], $imported_data_replacements ); |
| 749 | 740 | } |
| 750 | 741 | |
| 751 | 742 | if ( isset( $data['settings'] ) ) { |
| @@ -759,19 +750,8 @@ | ||
| 759 | 750 | } |
| 760 | 751 | |
| 761 | 752 | $document->save( $data ); |
| 762 | 753 | } |
| 763 | - } | |
| 764 | - | |
| 765 | - private function merge_atomic_prop_remap_warnings( array $warnings ): void { | |
| 766 | - if ( empty( $warnings ) ) { | |
| 767 | - return; | |
| 768 | - } | |
| 769 | - | |
| 770 | - $existing = $this->runners_import_metadata['atomic_prop_remap']['warnings'] ?? []; | |
| 771 | - $this->runners_import_metadata['atomic_prop_remap'] = [ | |
| 772 | - 'warnings' => array_merge( $existing, $warnings ), | |
| 773 | - ]; | |
| 774 | 754 | } |
| 775 | 755 | |
| 776 | 756 | private function update_instance_data_in_import_session_option() { |
| 777 | 757 | $import_sessions = Utils::get_import_sessions(); |