Repository navigation
Fix: getFeeds() error jika item RSS tidak punya author dan gagal per feed - #1812
Merged
Merged
Conversation
…feed (#1799) - DesaService::getFeeds() memakai nullsafe get_author()?->get_name() dengan fallback 'Administrator', sehingga item tanpa author tidak lagi dibuang. - Kegagalan satu feed desa dicatat (Log::warning) lalu dilewati, sehingga feed desa lain tetap tampil dan hasil kosong tidak ikut di-cache. - Ekstraksi makeFeedReader() dan mapFeedItem() agar dapat diuji tanpa jaringan. - Helper getFeeds() mendelegasikan ke DesaService; hapus import FeedsFacade (paket willvincent/feeds tidak terpasang). - Tambah test regresi DesaServiceFeedsTest. Co-Authored-By: Claude Opus 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.
Deskripsi
Pengambilan feed RSS desa memanggil
$item->get_author()->get_name() ?? 'Administrator'. SimplePie mengembalikannulldariget_author()bila item tidak punya author, sehingga->get_name()melempar error sebelum fallback??dipakai. Logika ini ada di dua tempat:DesaService::getFeeds()(dipakai halaman Berita Desa): error ditangkap per item, tetapi item tersebut dibuang, sehingga berita desa hilang dari halaman. Selain itu tidak ada penanganan per feed: bila satu feed desa melempar exception di luar loop item, seluruh hasil menjadi[]dan nilai kosong itu di-cache 1 jam.getFeeds(): tidak punyatry/catchsama sekali, dan memakaiwillvincent\Feeds\Facades\FeedsFacadeyang paketnya sudah tidak terpasang. Helper ini tidak dipanggil di repo, tetapi mungkin dipakai tema pihak ketiga.Perubahan yang dilakukan:
app/Services/DesaService.php$item->get_author()?->get_name() ?? 'Administrator'.try/catch (\Throwable): kegagalan dicatat denganLog::warning('Gagal mengambil feed desa', ...)lalu lanjut ke desa berikutnya.catchterluar menangkap\Throwable(sebelumnya hanyaException).makeFeedReader()danmapFeedItem()agar dapat diuji tanpa jaringan. Struktur array item tidak berubah.helpers/general_helper.php—getFeeds()kini mendelegasikan keDesaService::getFeeds(). ImportFeedsFacadedanDataDesayang tidak terpakai dihapus.tests/Unit/Services/DesaServiceFeedsTest.php(baru) memakai SimplePie asli dengan XML RSS mentah (tanpa jaringan).tests/Unit/Services/DesaServiceTest.php: hapus importFeedsFacadeyang tidak terpakai.Alasan perubahan:
nullpadaget_author()dan tidak adanya isolasi error per feed.Dampak perubahan:
✅ Item tanpa author tampil dengan author "Administrator".
✅ Feed gagal diisolasi: desa lain tetap tampil, kegagalan tercatat di log.
✅ Helper tidak error lagi dan tidak menduplikasi logika service.
✅ Format data tidak berubah untuk view dan tema.
Masalah Terkait (Related Issue)
Closes #1799
#1799
Catatan: setelah deploy, jalankan
php artisan cache:clearagar hasil feed kosong yang sempat tercache (desa_feeds) ikut terhapus.Langkah untuk mereproduksi (Steps to Reproduce)
Sebelum perbaikan (masalah):
getFeeds()menghasilkan error.Setelah perbaikan (fix):
laravel.logmemuatGagal mengambil feed desa.Testing pada fitur lain yang terkait:
DesaServiceFeedsTest✅ lolos (4 test baru, gagal sebelum perbaikan)DesaServiceTest✅ lolosWebsiteFooterTest✅ lolosPublicApiTest✅ lolospint --test✅ lolos untuk file yang diubahDaftar Periksa (Checklist)
Screenshots
🤖 Generated with Claude Code