Automated Maintenance (check_updates.php)
Overview
Pragma CMS separates the update-checking logic from the HTTP requests. Instead of slowing down the Admin UI by pinging external APIs on page load, a dedicated PHP CLI script runs in the background.
Execution
This script runs automatically via Cron at 04:00 and 16:00 under the www-data user to prevent cache permission conflicts.
To manually force an update check:
BASH
sudo -u www-data php /var/www/pragma-cms/scripts/cron/check_updates.php
How It Works
- CLI Security: The script immediately dies if accessed via a web browser (
php_sapi_name() !== 'cli'). - Minimal Bootstrapping: It loads only the absolute minimum classes required (
Platform.php,Database.php,UpdateManager.php,Site.php) to keep RAM usage near zero. - Cross-Tenant Routing: If an update is found, the script queries the master database to get the list of active sites. It then iterates through each tenant's
config_db.php, connects to their respective databases, and extracts theadmin_emailsetting. - Deduplication & Dispatch: Admin emails are deduplicated (
array_unique) to avoid spamming the same administrator. Notifications are then dispatched via PHPMailer using the Platform's Master SMTP settings.