Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions Controller/Admin/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1085,13 +1085,30 @@ protected function upsertAuthorityAndMember($em, $dir)
$insertValues[$col] = $data[$col] ?? 'member';
continue;
}
// 4.0系のカラム名マッピング
if ($col === 'work' && !array_key_exists($col, $data) && array_key_exists('work_id', $data)) {
$insertValues[$col] = $data['work_id'];
// 2.x系カラムマッピング (member_id → id, work → work_id, authority → authority_id, rank → sort_no)
if ($col === 'id' && !array_key_exists('id', $data) && array_key_exists('member_id', $data)) {
$insertValues[$col] = $data['member_id'];
continue;
}
if ($col === 'authority' && !array_key_exists($col, $data) && array_key_exists('authority_id', $data)) {
$insertValues[$col] = $data['authority_id'];
if ($col === 'work_id' && !array_key_exists('work_id', $data) && array_key_exists('work', $data)) {
$insertValues[$col] = (isset($data['del_flg']) && $data['del_flg'] == 1) ? 0 : $data['work'];
continue;
}
if ($col === 'authority_id' && !array_key_exists('authority_id', $data) && array_key_exists('authority', $data)) {
$insertValues[$col] = $data['authority'];
continue;
}
if ($col === 'sort_no' && !array_key_exists('sort_no', $data) && array_key_exists('rank', $data)) {
$insertValues[$col] = $data['rank'];
continue;
}
// del_flg == 1 の場合 email をダミーに
if ($col === 'email' && isset($data['del_flg']) && $data['del_flg'] == 1) {
$insertValues[$col] = StringUtil::random(60) . '@dummy.dummy';
continue;
}
if ($col === 'creator_id') {
$insertValues[$col] = !empty($data[$col]) ? $data[$col] : 1;
continue;
}
if (array_key_exists($col, $data)) {
Expand Down Expand Up @@ -1121,13 +1138,15 @@ protected function upsertAuthorityAndMember($em, $dir)
if (array_key_exists('two_factor_auth_key', $insertValues) && $insertValues['two_factor_auth_key'] === null) {
$insertValues['two_factor_auth_key'] = null; // NULL許可(この行は冗長だが明示的に残す)
}
$insertValues = $this->dataMigrationService->convertDataTypesForPostgreSQL($em, 'dtb_member', $insertValues);
$colsSql = implode(',', array_map(fn($c) => '"' . $c . '"', array_keys($insertValues)));
$placeholders = implode(',', array_fill(0, count($insertValues), '?'));
$updateSql = implode(', ', array_map(fn($c) => '"' . $c . '" = EXCLUDED."' . $c . '"', $updateCols));
$sql = 'INSERT INTO dtb_member (' . $colsSql . ') VALUES (' . $placeholders . ') ON CONFLICT (id) DO UPDATE SET ' . $updateSql;
$em->prepare($sql)->executeStatement(array_values($insertValues));
}
fclose($handle);
$this->dataMigrationService->setIdSeq($em, 'dtb_member');
}
// メンバーIDキャッシュ
try {
Expand Down
Binary file modified Tests/Fixtures/member_test.tar.gz
Binary file not shown.
9 changes: 8 additions & 1 deletion Tests/Web/Admin/ConfigControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ public function testバックアップファイルをアップロードできる

if ($m > 0) {
$members = $this->entityManager->getRepository(\Eccube\Entity\Member::class)->findAll();
self::assertEquals($m, count($members), 'メンバーが正しくインポートされること');
self::assertGreaterThanOrEqual($m, count($members), 'メンバーが正しくインポートされること');
// 移行データ固有の値を検証
$conn = $this->entityManager->getConnection();
$testAdmin = $conn->fetchAssociative(
'SELECT * FROM dtb_member WHERE id = ?', [99]
);
self::assertNotFalse($testAdmin, 'メンバーid=99が存在すること');
self::assertEquals('testadmin', $testAdmin['login_id']);
}

// ECCUBE_AUTH_MAGICの値を取得してアサート
Expand Down