Repository navigation
Fix: Detail komplain slug tidak ada jadi 404, dan hapus 3 route user yatim - #1803
Merged
analisopendesa merged 2 commits intoNov 23, 2026
Merged
Conversation
- SistemKomplainController::show() memakai firstOrFail() sehingga slug yang tidak ada menghasilkan 404, bukan error 500 saat membaca properti null. - Hapus route setting.user.password, setting.user.photo, dan setting.user.uphoto yang mengarah ke method yang tidak ada di UserController dan tidak dipakai di view mana pun. Closes #1802 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Contributor
|
🔄 AI PR Review sedang antri di server...
|
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.
Pull Request: Fix: Detail komplain slug tidak ada jadi 404, dan hapus 3 route user yatim
Deskripsi
Issue #1802 punya dua bug. (a) Membuka detail komplain dengan slug yang tidak ada menghasilkan error 500, karena
SistemKomplainController::show()memakaifirst()lalu langsung membaca$komplain->juduldari hasilnull. (b) Tiga routesetting.user.*mengarah ke method yang tidak ada diUserController, sehingga mengaksesnya melemparBadMethodCallException. PR ini memperbaiki (a) denganfirstOrFail()danabort(404), dan memperbaiki (b) dengan menghapus route yang tidak dipakai.Perubahan yang dilakukan:
app/Http/Controllers/FrontEnd/SistemKomplainController.phpmemakaifirstOrFail()dishow(), menangkapModelNotFoundExceptiondan mengembalikanabort(404). Error DB lain tetap masuk ke blokcatch (\Exception)yang sudah ada.routes/web.phpmenghapus tiga route yang mengarah ke method yang tidak ada:setting.user.password,setting.user.photo, dansetting.user.uphoto.tests/Feature/SistemKomplainControllerTest.phpmenambah test slug tidak ada harus 404.tests/Feature/Settings/UserOrphanRouteTest.php(file baru) memastikan ketiga route tersebut tidak terdaftar lagi.Alasan perubahan:
first()mengembalikannulluntuk slug yang tidak ada. Mengakses properti darinullmenyebabkan error 500, padahal seharusnya 404.Dampak perubahan:
✅ Detail komplain: slug tidak ada kini menghasilkan 404, bukan 500.
✅ Route user: tidak ada lagi route yang melempar
BadMethodCallException.✅ Tidak ada perubahan perilaku untuk route user yang dipakai (index, create, store, edit, update, updatePassword, destroy, active, permanent-destroy, getdata).
Masalah Terkait (Related Issue)
#1802
Langkah untuk mereproduksi (Steps to Reproduce)
Sebelum perbaikan (masalah):
GET /sistem-komplain/komplain/slug-ngawurAttempt to read property "judul" on null)setting.user.password,setting.user.photo, atausetting.user.uphotoyang mengarah ke method yang tidak adaBadMethodCallExceptionSetelah perbaikan (fix):
GET /sistem-komplain/komplain/slug-ngawursetting.user.*Testing pada fitur lain yang terkait:
SistemKomplainControllerTestlolos)get kirim form komplaindankomplain store with valid datalolos)UserManagementCrudTest,HttpVerbRouteTestlolos)UserControllerTestDaftar Periksa (Checklist)
route:list)Teknis Detail
Penjelasan Teknis
show()sekarang memakaiKomplain::where('slug', '=', $slug)->firstOrFail().ModelNotFoundExceptionditangkap lebih dulu dan diubah menjadiabort(404), sehingga tidak jatuh ke blokcatch (\Exception)yang mengembalikanback().setting/user. Tidak ada referensi ke nama route tersebut diresources/,app/,routes/, maupuntests/.Konfigurasi yang berubah
Tidak ada.
Dependencies yang ditambahkan
Tidak ada dependencies baru.
Testing
Manual Testing
setting.user.*setelah perubahan (php artisan route:list --name=setting.user)Automated Testing
SistemKomplainControllerTest: "detail komplain dengan slug tidak ada mengembalikan 404"UserOrphanRouteTest: route user yatim sudah dihapus (3 kasus)HttpVerbRouteTest,UserManagementCrudTest,PasswordHistoryTest,AdminKomplainControllerTest,Api/Frontend/KomplainControllerTest,SecurityTest: lolosCatatan:
UserControllerTest"update updates profile and red…" gagal dengan "Isian email sudah ada sebelumnya". Kegagalan yang sama terjadi pada koderilis-devtanpa perubahan PR ini, sehingga ini masalah data test yang sudah ada, bukan regresi.Browser Compatibility
Tidak berlaku (perubahan backend dan route).
Screenshots / Video
Tidak ada perubahan UI.
Breaking Changes
Tidak ada. Tiga route yang dihapus tidak dipakai di view atau tempat lain, dan tidak pernah berfungsi.
Migration Guide
Tidak diperlukan.
References
Catatan tambahan: Reviewer perlu memastikan tidak ada integrasi eksternal yang memanggil route
setting.user.password,setting.user.photo, atausetting.user.uphoto. Pencarian di repo tidak menemukan pemakaiannya.🤖 Generated with Claude Code