diff --git a/Controller/Admin/ConfigController.php b/Controller/Admin/ConfigController.php index 33f2872..7432da6 100644 --- a/Controller/Admin/ConfigController.php +++ b/Controller/Admin/ConfigController.php @@ -159,8 +159,11 @@ public function index(Request $request, Connection $em) // 全データ移行 $this->saveCustomer($em, $csvDir); + $this->releaseCustomerPhaseMemory(); $this->saveProduct($em, $csvDir); + $this->releaseProductPhaseMemory(); $this->saveOrder($em, $csvDir); + $this->releaseOrderPhaseMemory(); } // plg_customerplusの移行処理を作る @@ -1832,8 +1835,10 @@ private function saveToO($em, $tmpDir, $csvName, $tableName = null, $allow_zero } } - // shippingに紐付けるデータを保持 - $this->shipping_order[$data['id']] = $data; + // shippingに紐付けるデータを保持(必要なフィールドのみ) + $this->shipping_order[$data['id']] = [ + 'commit_date' => $data['commit_date'] ?? null, + ]; break; @@ -2343,4 +2348,30 @@ private function fix4x($em, $tmpDir, $csvName) return $i; // indexを返す } } + + private function releaseCustomerPhaseMemory(): void + { + $this->customer_point = []; + gc_collect_cycles(); + } + + private function releaseProductPhaseMemory(): void + { + $this->stock = []; + $this->product_images = []; + $this->dtb_class_combination = []; + $this->delivery_id = []; + $this->product_class_id = []; + gc_collect_cycles(); + } + + private function releaseOrderPhaseMemory(): void + { + $this->order_item = []; + $this->shipping_id = []; + $this->shipping_order = []; + $this->tax_rule = []; + $this->delivery_time = []; + gc_collect_cycles(); + } } diff --git a/Service/DataMigrationService.php b/Service/DataMigrationService.php index 8493e03..ade6d0a 100644 --- a/Service/DataMigrationService.php +++ b/Service/DataMigrationService.php @@ -44,6 +44,12 @@ class DataMigrationService */ private $mappingCache = []; + /** + * テーブルカラム情報のキャッシュ(テーブル名 => カラム配列) + * @var array + */ + private $tableColumnsCache = []; + /** * Customer item option data for migration * @var array @@ -178,7 +184,10 @@ public function convertDataTypesForPostgreSQL($em, $tableName, $data) try { - $columns = $em->getSchemaManager()->listTableColumns($tableName); + if (!isset($this->tableColumnsCache[$tableName])) { + $this->tableColumnsCache[$tableName] = $em->getSchemaManager()->listTableColumns($tableName); + } + $columns = $this->tableColumnsCache[$tableName]; $hasConversion = false; foreach ($data as $key => &$value) {