fix(ecommerce,board): 쿠폰 중복사용 라디오 boolean 문자열화로 저장이 422 실패하던 결함 수정
공개 제보(gnuboard/g7 @lyg-kaban): 관리자 쿠폰 폼의 「타 쿠폰과 중복 사용」 라디오를 클릭하면 자동바인딩이 DOM 문자열 "true"/"false" 를 폼 상태에 그대로 저장해 서버 boolean 규칙에서 422 로 저장이 실패했다. 표시 계층은 느슨 비교로 정상이라 저장 시점에야 드러나는 결함. - 레이아웃: is_combinable 라디오 autoBinding 해제 + String 표시 바인딩 + change 액션 === 'true' boolean 캐스팅 - 서버: Store/UpdateCouponRequest prepareForValidation 에서 문자열 표기 수용 boolean 정규화 (해석 불가값은 유지해 boolean 규칙이 422 처리) - 게시판 is_secret 동일 잠재 위험 서버 방어 + User Store/UpdatePostRequest 의 Board 직접 조회 4곳을 Repository 경유로 교체 (board 1.0.4) - 회귀: PHPUnit 11건(RED 선행) + 레이아웃 쓰기경로 타입 프로브 + E2E 왕복 spec + 시나리오 매니페스트(cases=32) - 재발 차단: ·AGENTS.md 금지 패턴 + audit 룰 layout-boolean-option-autobinding 신설(전수 0건) + 형제 룰 4종 extensions/** glob 누락 보강 + 트러블슈팅 사례 8 + 회귀 테스트
This commit is contained in:
1 parent
7c10f45aaf
commit
d675c8ac9f
22 files changed
+1060
-18
No files matched your search
@@ -11,8 +11,8 @@ use Illuminate\Validation\Rule;
|
||||
use Modules\Sirsoft\Board\Enums\PostStatus;
|
||||
use Modules\Sirsoft\Board\Http\Requests\Concerns\ResolvesAllowedExtensions;
|
||||
use Modules\Sirsoft\Board\Http\Requests\Concerns\ValidatesAttachmentCount;
|
||||
use Modules\Sirsoft\Board\Models\Board;
|
||||
use Modules\Sirsoft\Board\Models\Post;
|
||||
use Modules\Sirsoft\Board\Repositories\Contracts\BoardRepositoryInterface;
|
||||
use Modules\Sirsoft\Board\Rules\BlockedKeywordsRule;
|
||||
use Modules\Sirsoft\Board\Rules\CooldownRule;
|
||||
use Modules\Sirsoft\Board\Rules\ParentPostValidationRule;
|
||||
@@ -40,6 +40,28 @@ class StorePostRequest extends FormRequest
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 입력값을 정규화합니다.
|
||||
*
|
||||
* 비밀글 여부를 문자열 "true"/"false" 로 보내는 클라이언트도 수용하도록
|
||||
* boolean 으로 정규화합니다. (해석 불가값은 유지 → boolean 규칙이 422 처리)
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$merge = [];
|
||||
|
||||
if ($this->has('is_secret')) {
|
||||
$normalized = filter_var($this->input('is_secret'), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
||||
if ($normalized !== null) {
|
||||
$merge['is_secret'] = $normalized;
|
||||
}
|
||||
}
|
||||
|
||||
if ($merge) {
|
||||
$this->merge($merge);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
@@ -48,7 +70,7 @@ class StorePostRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
$slug = $this->route('slug');
|
||||
$board = Board::where('slug', $slug)->first();
|
||||
$board = app(BoardRepositoryInterface::class)->findBySlug((string) $slug);
|
||||
|
||||
// 게시판이 없으면 모듈 환경설정 기본값 사용
|
||||
$defaults = g7_module_settings('sirsoft-board', 'basic_defaults', []);
|
||||
@@ -225,7 +247,7 @@ class StorePostRequest extends FormRequest
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
$validator->after(function (Validator $validator) {
|
||||
$board = Board::where('slug', $this->route('slug'))->first();
|
||||
$board = app(BoardRepositoryInterface::class)->findBySlug((string) $this->route('slug'));
|
||||
$this->validateAttachmentTotal($validator, $board);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Modules\Sirsoft\Board\Enums\PostStatus;
|
||||
use Modules\Sirsoft\Board\Http\Requests\Concerns\ValidatesAttachmentCount;
|
||||
use Modules\Sirsoft\Board\Models\Board;
|
||||
use Modules\Sirsoft\Board\Repositories\Contracts\BoardRepositoryInterface;
|
||||
use Modules\Sirsoft\Board\Rules\BlockedKeywordsRule;
|
||||
|
||||
/**
|
||||
@@ -33,6 +33,28 @@ class UpdatePostRequest extends FormRequest
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 전 입력값을 정규화합니다.
|
||||
*
|
||||
* 비밀글 여부를 문자열 "true"/"false" 로 보내는 클라이언트도 수용하도록
|
||||
* boolean 으로 정규화합니다. (해석 불가값은 유지 → boolean 규칙이 422 처리)
|
||||
*/
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
$merge = [];
|
||||
|
||||
if ($this->has('is_secret')) {
|
||||
$normalized = filter_var($this->input('is_secret'), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
|
||||
if ($normalized !== null) {
|
||||
$merge['is_secret'] = $normalized;
|
||||
}
|
||||
}
|
||||
|
||||
if ($merge) {
|
||||
$this->merge($merge);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청에 적용할 검증 규칙
|
||||
*
|
||||
@@ -41,7 +63,7 @@ class UpdatePostRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
$slug = $this->route('slug');
|
||||
$board = Board::where('slug', $slug)->first();
|
||||
$board = app(BoardRepositoryInterface::class)->findBySlug((string) $slug);
|
||||
|
||||
if (! $board) {
|
||||
return [];
|
||||
@@ -134,7 +156,7 @@ class UpdatePostRequest extends FormRequest
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
$validator->after(function (Validator $validator) {
|
||||
$board = Board::where('slug', $this->route('slug'))->first();
|
||||
$board = app(BoardRepositoryInterface::class)->findBySlug((string) $this->route('slug'));
|
||||
$postId = $this->route('id');
|
||||
$this->validateAttachmentTotal($validator, $board, is_numeric($postId) ? (int) $postId : null);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user