SQL runner and maintenance: gates, undo log, clean-up
Rules of the SQL runner's read and update gates, the undo log, saved queries and logging, and the steps and safeguards of clearing the cache and temporary files.
The SQL runner and the maintenance clear are technical tools for the super administrator. Every endpoint is gated solely by isSuper(); the controller does not check the catalogue key system/sqlrunner + list, so assigning it grants no access.
Data model
Table names carry the installation's own prefix in the database.
| Table | Role |
|---|---|
sqlrunner_query | saved queries (name, text) |
sqlrunner_undo | undo log: table, affected rows, original values, state (applied, restored) |
Reading from any table; changes only on tables with the installation's prefix.
Gates
sqlrunner.run, read gate: comments stripped, forbidden keywords, multiple statements refused; allowed:SELECT,WITH,SHOW,DESCRIBE,EXPLAIN; enforced limit of 500 rows; result list and full copyable result.- Update gate (
UPDATE): one table with the installation prefix, requiredWHERE, simple SET columns, at most 2000 rows. Without confirmation it only counts; withconfirm=1it saves the original values in a transaction and runs; success with an undo entry read back. sqlrunner.undolist(50 entries),sqlrunner.undorestore: active entries only; rows changed or deleted since are named.sqlrunner.queries,savequery(new or overwrite, read back),deletequery.
Every run, successful or rejected, goes to the system log and the framework's error log; updates with a masked statement.
Maintenance clear
maintenance.clear (header broom, isSuper() only, no own key):
- framework cache, template cache, query cache files, OPcache;
- the module's temporary files and the backups' work folders: only files older than 6 hours are removed; partial files of open uploads and the work directory of running iPhone backups are protected (the protected list comes from the
backup/iphonebackupmodel); if the protected list cannot be read, nothing is cleaned.
Reply: removed counts, freed bytes, kept files; a log line.
Permissions
Super administrator only; other users get the no-permission page for the SQL runner. The menu item is also shown to the super administrator only.