Skip to content

System create a new file upload system where all files are saved in a central table#2076

Open
ali-ichk wants to merge 42 commits intoGibbonEdu:v31.0.00from
ali-ichk:System-Create-a-new-file-upload-system-where-all-files-are-saved-in-a-central-table
Open

System create a new file upload system where all files are saved in a central table#2076
ali-ichk wants to merge 42 commits intoGibbonEdu:v31.0.00from
ali-ichk:System-Create-a-new-file-upload-system-where-all-files-are-saved-in-a-central-table

Conversation

@ali-ichk
Copy link
Contributor

Gibbon currently lacks centralized tracking of file uploads across the system. When files are uploaded through various modules, there's no systematic way to track which files exist, identify orphaned files when records are deleted, audit file usage, or implement file lifecycle management. This change introduces a comprehensive file tracking infrastructure that records all file uploads in new gibbonFile and gibbonFilePointer tables, providing metadata tracking and relationship mapping between files and database records. The FileHandler class provides a unified API for recording, deleting, and querying file uploads. Foreign key constraints ensure automatic cleanup of file records when parent records are deleted. This foundation enables future features like storage analytics, orphaned file cleanup, file retention policies, and audit trails while maintaining full backward compatibility with existing upload functionality.

Description
File Upload Tracking System
Added comprehensive file upload tracking system to monitor and manage all file uploads across the system
Added new database tables gibbonFile and gibbonFilePointer to track file metadata and relationships
Added FileHandler class to centralize file tracking operations (record, delete)
Added FileGateway and FilePointerGateway for database operations
Integrated file tracking across 12 modules covering 40+ file upload locations:
- Planner Module: units, homework submissions, and resources (6 files)
- Departments Module: department resources (1 file)
- Staff Module: staff contracts with bug fixes (1 file)
- Free Learning Module: unit logos and student work (4 files)
- Parent Photo Upload: profile images with bug fixes (1 file)
- Professional Development Module: supporting evidence and expense receipts (2 files)
- Enrichment and Flow Module: domain, credit, and opportunity logos, journey evidence (7 files)
- Flexible Learning Module: unit submission evidence (2 files)
- Policies Module: policy documents (2 files)
- Info Grid Module: entry logos (2 files)
- Committees Module: committee logos (2 files)
Implemented consistent file deletion tracking when files are removed or replaced
Added partial failure handling to report tracking issues without blocking uploads

Motivation and Context
Currently, Gibbon lacks centralized tracking of file uploads across the system. When files are uploaded through various modules (Planner, Staff, Free Learning, etc.), there's no systematic way to:

Track which files exist in the system and where they're stored
Identify orphaned files when database records are deleted
Audit file usage and relationships across tables
Implement file lifecycle management (retention policies, cleanup)
Generate reports on storage usage by module or user
Ensure data integrity between filesystem and database

How Has This Been Tested?

Testing Environment
PHP version: PHP 8.3
Database: MySQL
Gibbon version: v31.0.00
Modules tested: 12 modules across 40+ file upload locations

Testing was performed across 12 modules covering 40+ file upload locations including Planner, Staff, Free Learning, Professional Development, Enrichment and Flow, Flexible Learning, Policies, Info Grid, Committees, Departments, and Parent Photo Upload modules. Database schema was validated to ensure tables, foreign keys, and indexes were created correctly. Core infrastructure testing confirmed FileHandler::recordFileUpload() and FileHandler::deleteFile() work properly with various file types. Each module's add and edit operations were tested to verify files upload correctly, tracking records are created in the database, file replacements work, and deletion tracking functions properly. Error handling was tested to ensure tracking failures don't block successful uploads (partial failure returns warning1). Regression testing confirmed all existing upload functionality works unchanged with no breaking changes to module behavior. The implementation is transparent to end users and maintains full backward compatibility.

Test Results
All 40+ file upload locations successfully integrated
File tracking records created correctly in database
File deletion tracking works as expected
No regressions in existing upload functionality
Bug fixes verified and working correct

FileGateway.php - All 6 required methods are complete: recordFileUpload(), recordFileUploadWithPointer(), selectFilesByForeignRecord(), selectOrphanedFileRecords(), verifyFileIntegrity(),
FilePointerGateway.php - Core method implemented: recordFilePointer()
…ss. Implemented the new Gateway class in 5 locations where a file is being uploaded.
Copy link
Member

@SKuipers SKuipers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Ali, I've started a review and have flagged some spots to have a look at before I merge.

ali-ichk and others added 3 commits March 20, 2026 15:22
Co-authored-by: Sandra Kuipers <sandra@skuipers.com>
…are-saved-in-a-central-table' of https://github.com/ali-ichk/core into System-Create-a-new-file-upload-system-where-all-files-are-saved-in-a-central-table

* 'System-Create-a-new-file-upload-system-where-all-files-are-saved-in-a-central-table' of https://github.com/ali-ichk/core:
  Apply suggestions from code review
@ali-ichk ali-ichk requested a review from SKuipers March 20, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants