fix #4253 【ブログ】初期記事を複製した際にアイキャッチが複製されない件を修正#4396
Open
kaburk wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
よろしくお願いします。