Skip to content

fix #4253 【ブログ】初期記事を複製した際にアイキャッチが複製されない件を修正#4396

Open
kaburk wants to merge 1 commit into
baserproject:5.2.xfrom
kaburk:5.2.x-#4253
Open

fix #4253 【ブログ】初期記事を複製した際にアイキャッチが複製されない件を修正#4396
kaburk wants to merge 1 commit into
baserproject:5.2.xfrom
kaburk:5.2.x-#4253

Conversation

@kaburk
Copy link
Copy Markdown
Collaborator

@kaburk kaburk commented May 22, 2026

よろしくお願いします。

Copilot AI review requested due to automatic review settings May 22, 2026 10:50
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

ブログの「初期記事」を複製した際、アイキャッチ画像がテーマ(コアフロントテーマ)の webroot/files 側に存在するケースで複製されない問題(#4253)に対応するPRです。ファイル探索のフォールバックを追加し、再現ケースをテストで担保しています。

Changes:

  • BcFileUploader::renameToBasenameField() で、通常の保存先・テーマ保存先に見つからない場合に「コアフロントテーマの files」も探索するフォールバックを追加
  • 上記の挙動をカバーするため、ブログ記事複製時のアイキャッチ複製テストを拡充(初期記事=テーマ内 files からのコピーも追加)
  • テストのアップロード入力を UploadedFile 形式へ更新

Reviewed changes

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

File Description
plugins/bc-blog/tests/TestCase/Model/BlogPostsTableTest.php 初期記事(テーマ内 files)のアイキャッチが複製されることを確認するテストケースを追加
plugins/baser-core/src/Utility/BcFileUploader.php テーマ側にある初期データ画像の探索フォールバック(コアフロントテーマ)を追加

Comment on lines +657 to 660
$themeFilesDir = ROOT . DS . 'plugins' . DS . 'bc-front' . DS . 'webroot' . DS . 'files' . DS . 'blog' . DS . '999';
if (is_dir($themeFilesDir)) {
$folder = new BcFolder($themeFilesDir);
$folder->delete();
Comment on lines +757 to +777
// 初期記事を複製 → テーマ内ファイルから webroot/files へコピーされる
$copiedInitPost = $this->BlogPostsTable->copy(null, clone $initialPost);

// アイキャッチが webroot/files 配下に複製されているか
$this->assertNotEmpty($copiedInitPost->eye_catch);
$copiedEyeCatch = $copiedInitPost->eye_catch;
$this->assertTrue(is_file(WWW_ROOT . 'files/blog/999/blog_posts/' . $copiedEyeCatch));
$thumbPath = str_replace('_eye_catch.', '_eye_catch__thumb.', $copiedEyeCatch);
$this->assertTrue(is_file(WWW_ROOT . 'files/blog/999/blog_posts/' . $thumbPath));
$mobileThumbPath = str_replace('_eye_catch.', '_eye_catch__mobile_thumb.', $copiedEyeCatch);
$this->assertTrue(is_file(WWW_ROOT . 'files/blog/999/blog_posts/' . $mobileThumbPath));

// 複製元(テーマ内)のファイルは残っているか
$this->assertEquals($initEyeCatch, $initialPost->eye_catch);
$this->assertTrue(is_file($themePostDir . '00000099_eye_catch.png'));

// Cleanup
$dir = new BcFolder(WWW_ROOT . 'files/blog/999');
$dir->delete();
$themeDir = new BcFolder($themeFilesDir);
$themeDir->delete();
Comment on lines +960 to +967
$frontTheme = Configure::read('BcApp.coreFrontTheme');
if (!$frontTheme) return false;
$pluginPath = ROOT . DS . 'plugins' . DS;
if (is_dir($pluginPath . $frontTheme)) {
$basePath = $pluginPath . $frontTheme . DS . 'webroot' . DS . 'files' . DS;
} elseif (is_dir($pluginPath . Inflector::dasherize($frontTheme))) {
$basePath = $pluginPath . Inflector::dasherize($frontTheme) . DS . 'webroot' . DS . 'files' . DS;
} else {
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.

2 participants