Skip to content

fix #4324 【サブサイト】「エイリアスを利用してメインサイトと自動連携する 」にチェックを入れると、メインサイトの設定が変更できない問題を修正#4352

Merged
ryuring merged 1 commit intobaserproject:5.2.xfrom
kaburk:5.2.x-#4324
Apr 15, 2026

Conversation

@kaburk
Copy link
Copy Markdown
Collaborator

@kaburk kaburk commented Apr 8, 2026

よろしくお願いします!

Copilot AI review requested due to automatic review settings April 8, 2026 05:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

本PRは、サブサイトで「エイリアスを利用してメインサイトと自動連携する」を有効にしている場合に、メインサイト側のルートコンテンツ更新がサブサイト側のルート情報(URL名など)を崩してしまい、設定変更に支障が出る問題(#4324)を修正するものです。

Changes:

  • ContentsTable::updateRelateSubSiteContent() で、メインサイトの site_root 更新時に連携先サブサイトのルートコンテンツ名をサイト側の alias/name に合わせて維持するよう変更
  • 同ケースで、連携先サブサイトのルートコンテンツの parent_id をメインサイトのルートに固定し、不正なツリー更新を回避
  • 上記挙動を検証するユニットテストを追加

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
plugins/baser-core/src/Model/Table/ContentsTable.php メインサイトのルート更新時に、連携サブサイト側のルートコンテンツの name/parent_id を適切に扱うロジックへ修正
plugins/baser-core/tests/TestCase/Model/Table/ContentsTableTest.php メインサイトの site_root 更新で連携先サブサイトのURL名が維持されることを確認するテストを追加

Comment on lines +390 to +392
} else {
$sitesTable->updateAll(['status' => true], ['id' => 2]);
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このテストは Sites テーブルの状態に依存しており、id=2 のレコードが既に存在する場合に relate_main_sitealias が期待値(例: smartphoneサイトの設定)になっている保証がありません。SitesScenario::class を load する、または id=2 の Site エンティティを取得して relate_main_site=true / alias='s' を含めて明示的に更新してから検証する形にすると、テストが環境依存になりにくいです。

Suggested change
} else {
$sitesTable->updateAll(['status' => true], ['id' => 2]);
}
}
$sitesTable->updateAll([
'status' => true,
'relate_main_site' => true,
'alias' => 's',
], ['id' => 2]);

Copilot uses AI. Check for mistakes.
Comment on lines +393 to +394
$this->Contents->updateAll(['name' => 's'], ['id' => 23]);

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

テスト内で id=23 を直接参照していますが、これは「site_id=2 のルートコンテンツID」である前提に強く依存します。$sitesTable->getRootContentId(2) で取得したIDを使うと、フィクスチャ/シナリオ変更時にも意図が明確で壊れにくくなります。

Copilot uses AI. Check for mistakes.
@ryuring
Copy link
Copy Markdown
Collaborator

ryuring commented Apr 9, 2026

@kaburk コンフリクトしちゃってますので、調整をお願いしていいですか?

@ryuring ryuring merged commit a7a4b6b into baserproject:5.2.x Apr 15, 2026
1 check passed
@momofff momofff added this to the 5.2.4 milestone Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants