fix #2964 【システム】BcUploadでアップしたファイルをバリデーションエラー時に維持する#4397
Open
kaburk wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
本PRは、BcUpload でアップロードしたファイルについて、バリデーションエラー時でも {field}_tmp を維持してプレビュー/再表示できるようにする対応(#2964)を、コア(BcFileUploader / BcUploadBehavior / BcFormHelper / BcUploadHelper)および関連プラグイン(BcMail / BcSeo / BcContentsBehavior)にまたがって整備するものです。
Changes:
- BcUpload の afterMarshal / rollback 処理を拡張し、バリデーションエラー時にアップロードファイルをセッションへ退避・復元しやすくする
- Form/Upload 系 Helper を拡張し、
{field}_tmphidden の出力や tmp 画像リンク生成を改善 - 上記挙動に対応するテスト追加・安定化(順序依存の解消、tmp ファイル名の許容など)
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/bc-theme-file/src/Service/ThemeFoldersService.php | テーマファイル一覧でドット開始の隠しファイル/フォルダを除外 |
| plugins/bc-seo/tests/TestCase/Event/BcSeoModelEventListenerTest.php | seo_meta 経路別に afterMarshal で tmp が保持されることのテスト追加 |
| plugins/bc-seo/src/Event/BcSeoModelEventListener.php | バリデーションエラー時に SeoMetas のファイル系を rollback して tmp を維持 |
| plugins/bc-mail/tests/TestCase/View/Helper/MailformHelperTest.php | フロントフォームで tmp プレビュー用 hidden/URL が出ることのテスト追加 |
| plugins/bc-mail/tests/TestCase/Service/Front/MailFrontServiceTest.php | confirm で成功/失敗/再送時に tmp を維持するテスト追加 |
| plugins/bc-mail/tests/TestCase/Model/Table/MailMessagesTableTest.php | afterMarshal で rollbackFile 副作用(tmp/セッション退避)を検証 |
| plugins/bc-mail/src/View/Helper/MailformHelper.php | file() を上書きし MailMessages テーブル設定で tmp 表示を有効化 |
| plugins/bc-mail/src/Service/Front/MailFrontService.php | confirm 失敗時に afterMarshal が生成した _tmp を引き継ぐ |
| plugins/bc-mail/src/Model/Table/MailMessagesTable.php | valid_ex の null 安全化等(tmp 二重処理回避のコメント追加) |
| plugins/bc-mail/src/Controller/MailController.php | captcha エラー時も tmp を作って引き継ぐように調整 |
| plugins/bc-blog/tests/TestCase/View/Helper/BlogHelperTest.php | tmp URL の期待値を拡張子付きに修正 |
| plugins/bc-blog/tests/TestCase/Controller/BlogControllerTest.php | タグ検索の順序依存を解消 |
| plugins/baser-core/tests/TestCase/View/Helper/BcUploadHelperTest.php | tmp 値優先/自動判定/リンク有無などのテスト追加・期待値更新 |
| plugins/baser-core/tests/TestCase/View/Helper/BcFormHelperTest.php | table オプション/_tmp hidden 出力(ネスト含む)のテスト追加 |
| plugins/baser-core/tests/TestCase/View/Helper/BcBaserHelperTest.php | theme config の出力差異を吸収してテスト安定化 |
| plugins/baser-core/tests/TestCase/Utility/BcFileUploaderTest.php | tmp 名のタイムスタンプ許容、rollback/setupTmpData 等のテスト大量追加 |
| plugins/baser-core/tests/TestCase/Model/Behavior/BcUploadBehaviorTest.php | afterMarshal rollback / accessibleFields 追加のテスト追加 |
| plugins/baser-core/tests/TestCase/Model/Behavior/BcContentsBehaviorTest.php | Content アソシエーションの rollback をテスト追加 |
| plugins/baser-core/tests/TestCase/Controller/UploadsControllerTest.php | TMP/uploads ディレクトリ作成の安全化 |
| plugins/baser-core/tests/TestCase/Controller/Api/Admin/ThemesControllerTest.php | テーマ一覧の順序依存を解消 |
| plugins/baser-core/src/View/Helper/BcUploadHelper.php | tmp 優先ロジック・ネスト対応・tmp でもリンクを出す等の改善 |
| plugins/baser-core/src/View/Helper/BcFormHelper.php | file() で table 指定・tmp hidden 出力・type=file は file() 直呼びに変更 |
| plugins/baser-core/src/Utility/BcFileUploader.php | setupTmpData/rollbackFile/saveTmpFile/session 削除方針などを拡張 |
| plugins/baser-core/src/Model/Behavior/BcUploadBehavior.php | beforeMarshal で _tmp を accessible に、afterMarshal で関連Entityも rollback |
| plugins/baser-core/src/Model/Behavior/BcContentsBehavior.php | 親Entityエラー時に Content 側の rollback を強制実行 |
Comment on lines
+800
to
+809
| // optionsで明示的にtableが指定されている場合はそれを使う(動的アソシエーション対応) | ||
| if (!empty($options['table'])) { | ||
| try { | ||
| $table = TableRegistry::getTableLocator()->get($options['table']); | ||
| } catch (\Exception $e) { | ||
| $table = $this->getTable($fieldName); | ||
| } | ||
| } else { | ||
| $table = $this->getTable($fieldName); | ||
| } |
Comment on lines
+213
to
+224
| $imgExts = []; | ||
| try { | ||
| $ref = new \ReflectionClass($behavior); | ||
| if ($ref->hasProperty('BcFileUploader')) { | ||
| $prop = $ref->getProperty('BcFileUploader'); | ||
| $prop->setAccessible(true); | ||
| $bcFileUploader = $prop->getValue($behavior); | ||
| if ($bcFileUploader && isset($bcFileUploader[$alias]) && property_exists($bcFileUploader[$alias], 'imgExts')) { | ||
| $imgExts = $bcFileUploader[$alias]->imgExts; | ||
| } | ||
| } | ||
| } catch (\ReflectionException $e) {} |
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.
よろしくお願いします。