-
Notifications
You must be signed in to change notification settings - Fork 141
fix #4226 【コンテンツ】コンテンツフォルダ内にindexを作成していない場合に、フォルダ内のページの一覧を表示するか選択できるよ… #4227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…を表示するか選択できるよう機能を追加
|
エラーが今回の改修と関係ないCustomContentsで出ているようです。 |
|
@katokaisya 色々設定まわりをやっていただいて、申し訳ないのですが、今回、 設定機能は不要と思っていました。 |
|
@katokaisya ユニットテストのエラーは、本家の最新版をマージしてから再度プッシュして頂けるとなおるはずです。 |
|
@ryuring 設定漏れを無くすため、DBだけでなく、.envで上書きできるように調整しています。 |
本家の5.1.xをプルしていますがユニットテストが通らないようです。 |
こちらはコンテンツが存在する前提ですよね?
該当コントローラアクションへのブラウザアクセスが権限が不足しているかどうかというのは、CMS側の勝手な都合です。 |
|
env切り替え機能のみ外す |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a configuration option to control the behavior of content folders when they don't have an index page. Instead of showing a folder listing, administrators can now choose to return a 403 Forbidden response.
- Added a checkbox setting in the site configuration to disable content folder index functionality
- Implemented logic to throw a ForbiddenException when the setting is enabled
- Added environment variable support (FOLDER_INDEX="Forbidden") that takes priority over the UI setting
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| plugins/bc-admin-third/templates/Admin/SiteConfigs/index.php | Added UI checkbox for controlling content folder index behavior with environment variable override |
| plugins/baser-core/src/Controller/ContentFoldersController.php | Implemented 403 response logic when content folder index is disabled |
| config/.env.example | Added documentation for the FOLDER_INDEX environment variable |
| $checed['checked'] = env('FOLDER_INDEX') == 'Forbidden' ? 'checked' : false; | ||
| if ($checed['checked']) { |
Copilot
AI
Aug 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable name has a typo: '$checed' should be '$checked'.
| $checed['checked'] = env('FOLDER_INDEX') == 'Forbidden' ? 'checked' : false; | |
| if ($checed['checked']) { | |
| $checked['checked'] = env('FOLDER_INDEX') == 'Forbidden' ? 'checked' : false; | |
| if ($checked['checked']) { |
| $checed['checked'] = env('FOLDER_INDEX') == 'Forbidden' ? 'checked' : false; | ||
| if ($checed['checked']) { |
Copilot
AI
Aug 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable name has a typo: '$checed' should be '$checked'.
| $checed['checked'] = env('FOLDER_INDEX') == 'Forbidden' ? 'checked' : false; | |
| if ($checed['checked']) { | |
| $checked['checked'] = env('FOLDER_INDEX') == 'Forbidden' ? 'checked' : false; | |
| if ($checked['checked']) { |
| } else { | ||
| echo $this->BcAdminForm->control('use_contents_folder_forbidden', [ | ||
| 'type' => 'checkbox', | ||
| $checed, |
Copilot
AI
Aug 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable name has a typo: '$checed' should be '$checked'.
| $checed, | |
| $checked, |
| ?> | ||
| <i class="bca-icon--question-circle bca-help"></i> | ||
| <div class="bca-helptext"> | ||
| <?php echo __d('baser_core', 'indexページの無いコンテツフォルダにアクセスした際に、<br>index機能を使わずに403を返します。<br> config/.envでも export FOLDER_INDEX="Forbidden" の記述で設定できます。') ?> |
Copilot
AI
Aug 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in Japanese text: 'コンテツフォルダ' should be 'コンテンツフォルダ' (missing 'ン').
| <?php echo __d('baser_core', 'indexページの無いコンテツフォルダにアクセスした際に、<br>index機能を使わずに403を返します。<br> config/.envでも export FOLDER_INDEX="Forbidden" の記述で設定できます。') ?> | |
| <?php echo __d('baser_core', 'indexページの無いコンテンツフォルダにアクセスした際に、<br>index機能を使わずに403を返します。<br> config/.envでも export FOLDER_INDEX="Forbidden" の記述で設定できます。') ?> |
| $siteConfig = $siteConfigsService->get(); | ||
| if (!empty($siteConfig->use_contents_folder_forbidden) || env('FOLDER_INDEX') == 'Forbidden') { | ||
| throw new \Cake\Http\Exception\ForbiddenException(__d('baser_core', 'indexページが見つかりませんでした。')); | ||
| exit; |
Copilot
AI
Aug 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'exit;' statement is unreachable code because the ForbiddenException on the previous line will stop execution. This line should be removed.
| exit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@katokaisya throw した場合はそこで処理が終了するので、exitはいらないです
|
@ryuring |
|
@katokaisya copilotのレビューが入ってますので見ておいてください |
|
@ryuring |
| $siteConfig = $siteConfigsService->get(); | ||
| if (!empty($siteConfig->use_contents_folder_forbidden) || env('FOLDER_INDEX') == 'Forbidden') { | ||
| throw new \Cake\Http\Exception\ForbiddenException(__d('baser_core', 'indexページが見つかりませんでした。')); | ||
| exit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@katokaisya throw した場合はそこで処理が終了するので、exitはいらないです
|
@katokaisya ありがとうございます、マージしました。 |
…う機能を追加
@ryuring
@uchin0
DB構造を変更しなくて済むように
システム基本設定 →サイト設定に切り替え機能を追加しました。
また、.envファイルでも設定できるようにしています。
その場合はシステム基本設定の画面のチェックボックスは省略されます。
