-
Notifications
You must be signed in to change notification settings - Fork 0
Implement caching-based comment rendering system for Smarty 3.x #80
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
base: features/smarty-v3-feature
Are you sure you want to change the base?
Implement caching-based comment rendering system for Smarty 3.x #80
Conversation
|
@copilot here are the answers requested:
All supported types from the database: Only the
This also makes cache invalidation more efficient on a per comment basis; see below.
When per comment cache exists, its cache must only be renewed when the comment is being edited. But it must also remove the cached item, when a comment is manually deleted by a user.
As the commenting system is pluggable / universally, it must be migrated directly supporting all types of boards.
Nowadays the bottleneck is the browser's rendering engine of huge html pages / dom sizes. We have items with more than 200 1st-level comments (= these are always shown, as directly below the root item / thread). It must support that, but no async loading on the frontend or something like that - we'll stick to fully server side rendering, but speeding up heavily using cached comments (or whatever helps to achieve speed, e.g. still use a compiled template per thread item structure? Not sure). |
- Created CommentsCache class for managing comment caches - Created new render_comment_cached() functions using Smarty 3.x native caching - Modified Smarty_Resource_Comments to use new rendering system - Replaced compile_template() calls with cache invalidation in Comment::update() and comment_delete.php - Individual comment caching with user-depth awareness - Cache invalidation on edit/delete only (not on replies) - Added design document explaining architecture Co-authored-by: oliveratgithub <[email protected]>
Implemented caching-based comment rendering system based on your specifications (commit 4de91a6). Key Features:
Architecture:
What Changed:
Testing Needed:
Ready for your review and testing. Let me know if you'd like me to make any adjustments to the caching strategy or implementation. |
The custom Smarty compiler for threaded comments generates compiled templates (template_c) per comment/thread instead of using rendered caches, creating performance bottlenecks and preventing PHP 8.2+ migration.
Implementation Complete
This PR implements a complete caching-based rendering system that replaces the custom Smarty compiler with Smarty 3.x native caching features.
Current Architecture Analysis
Custom Resource Handler Pattern:
Problems Identified:
{include file="comments:ID"}forces recompilationImplemented Solution
1. New Caching System
Created
CommentsCacheclass (comments_cache.inc.php) that manages:comment_{board}_{comment_id}_{user_depth}2. New Rendering Functions
Created caching-aware rendering system (
comments_render.inc.php):render_comment_cached()- Uses Smarty 3.x native caching instead of compilationrender_childposts_cached()- Recursive child comment rendering with cachingrender_comment_tree()- Main entry point for rendering complete comment treesrender_comment_tree_smarty_wrapper()- Smarty plugin interface3. Cache Invalidation Integration
Modified existing code to use cache clearing instead of recompilation:
Comment::update()inforum.inc.php- Clears cache for edited comment + parentcomment_delete.php- Clears cache for deleted comment + parentSmarty_Resource_Comments::fetch()- Updated to use new rendering system4. Board Type Support
Universal support for all 12 board types:
5. User Depth Handling
$user->maxdepthandDEFAULT_MAXDEPTH=7Caching Strategy
Cache Invalidation Triggers:
Files Created
/www/includes/comments_cache.inc.php- Cache management class/www/includes/comments_render.inc.php- Caching-aware rendering functions/REFACTORING_DESIGN.md- Complete architecture documentation/IMPLEMENTATION_SUMMARY.md- Detailed implementation guideFiles Modified
/www/includes/smarty.inc.php- Updated resource handler, registered new functions/www/includes/forum.inc.php- Replaced compile with cache clearing inComment::update()/www/actions/comment_delete.php- Added cache invalidation on deleteExpected Performance Benefits
Testing Required
The implementation is complete and ready for testing:
Documentation
Complete documentation included:
REFACTORING_DESIGN.md)IMPLEMENTATION_SUMMARY.md)Next Steps
del_compiled_comments.phpaction once stableOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.