Repository navigation
Render templates without warnings when a site has no sections - #656
Conversation
The body and entries-list class builders read the current section's name unconditionally, so a site with no sections raised "Trying to access array offset on null" on every template. Add the section-name classes only when a current section exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughBoth template render services now add section-name classes only when a current section exists. Tests cover rendered classes for sites with no sections and with an ChangesSection class rendering
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to Pages without a current section omit only section-name classes, while retaining the default section type and entry-list classes. No actionable merge risk is established. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
On a site with no sections, every template showed PHP warnings:
The body and entries-list class builders read
$currentSection['name']even when there is no current section. They now addxContent-<name>andxSection-<name>only when a section exists, as the editor'sSectionRenderService.getBodyClasses()already does.xSectionType-defaultis still added, so styles based on section type still apply. Pages that have a section get the same classes as before.SectionTemplateRenderService:getBodyClasses()andgetPageEntriesAttributes()(Default, White, Mashup)MessyTemplateRenderService:getBodyClassList()andgetPageEntriesClasses()Testing
tests/Feature/SectionTemplateRenderServiceTest.phpcovers both services with no sections and with a section. Before the fix it fails with the same warning; it passes now.🤖 Generated with Claude Code
Summary by CodeRabbit