Update Manager: state machine, checks and background jobs

The full update chain: registration, check, the download-and-prepare state machine, activation steps, health check, settings, the two background jobs and the permission keys.

The Update Manager controls the installation's update process, connected to the central release server. The controller is thin: the logic lives in the update service library, the SQL in the system/update and system/migrate models. Permissions are requested through a helper that calls canAction, so the automatic extractor shows no keys, but the keys are actually checked.

Data model

Table names carry the installation's own prefix in the database.

TableRole
update_configserver, channel, automatic mode, window, interval, backup target, registration (ID, secret, key version), last check result
update_runupdate and backup runs with a state machine
update_loglog lines per run
update_backupbackups (dump + code zip), verification state
migrationhistory of versioned migrations

Process

  1. Registration (update.register): installation ID + one-time code to the server's register endpoint; the returned secret, key version, channel and operating model are stored. In local mode (this installation is the release server) through local transport.
  2. Check (update.check): signed request with ETag support; classification up_to_date, available, not_allowed, unreachable, revoked, unregistered. No package is downloaded.
  3. Preparation (update.start, update.advance, update.cancel): one run at a time; the state machine advances in 15-second slices: authorize → download (resumable, at most 3 attempts per token) → verify (manifest signature, size, SHA-256, PHP and framework requirements, minimum previous version) → stage (unpack into the staging directory, tree check) → preflight (drift, syntax, dependencies, writability, twice the free space) → backup → ready. Without approval: waiting_approval. Cancel only before activation, deleting staging and partial download.
  4. Activation (update.approve): maintenance mode with 30-minute self-expiry; waits at most 60 s for the running scheduler worker (otherwise waiting_window); installs the current version's recovery tool, web recovery for 24 hours; differential backup; versioned migrations from the staging tree (on error the code is not swapped); schema compatibility measurement; directory swap with two renames (previous tree under previous/); vendor sync; OPcache and template cache cleared.
  5. Health check: HTTP probe to the catalog endpoint api/update.health with a one-time token; if the server cannot reach itself, verify_pending, confirmed by the next admin page load. Faulty new code is swapped back automatically if the schema is additive.
  6. Success: installed version raised, notification, report to the server; previous/ keeps at most 2 trees, failed/ at most 1. update.retry reruns failed versioned migrations.

Background jobs

JobBehaviour
update_checksystem level, always on; skipped on unregistered installations; forced check; without an active run it picks up central requests (install only if central installation is allowed, otherwise prepare and wait for approval); notifies once about a new version; in patch mode starts the eligible, licensed PATCH step. Rescheduling: interval + 0–59 minutes derived from the installation ID + 0–9 random minutes.
update_applyevent job: advances the active run without waiting for the worker lock; if not final, requeues itself after 1 minute, or after 15 minutes while waiting for approval or the window, with duplicate protection.

Settings and validation

update.save: server URL (https:// only), channel (stable, beta, dev), automatic mode (off, patch), window (HH:MM-HH:MM), interval 1–168 hours, accept direct deployment, accept central install requests, backup target (local, gdrive + account + folder), backups kept 1–20, notification e-mail. Error keys: error_value, error_window, error_backup_gdrive, error_https. Google accounts are loaded only with the settings permission.

Permissions

KeyClassOpens
listSYSTEMpage, status, runs, backups, migrations
checkSYSTEMcheck
downloadSUBSCRIPTIONpreparation; advance and cancel with download or install
installSYSTEMinstall, approve, retry
settings, registerSYSTEMsettings, registration
debugSYSTEMnot read by the templates; no effective use can be determined

No content scope: installation-level technical data. Token, manifest, signature and internal backup state are never sent out with run data. The central server ties downloading to the system/update + download function permission of the client's users and an active subscription.

Known limitations

The full chain has been tested on a real database with local transport; it has not yet run on a live central server with a real signing key, HTTPS transport and a real Drive archive.