Skip to content

[AI] [6.3] Health Check: database check - #96

Open
obuisard wants to merge 25 commits into
6.3-devfrom
pr-22
Open

obuisard wants to merge 25 commits into
6.3-devfrom
pr-22

Conversation

@obuisard

@obuisard obuisard commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Copy of obuisard/joomla-cms#22

Included plugins you can install:
database.zip

genr8r and others added 25 commits October 17, 2026 13:20
…h check

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ding

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ures

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k texts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd harden Check now

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ro-date status line

- Convert MySQL UPDATE_TIME (session time zone) to UTC via UNIX_TIMESTAMP.
- Park Details dialog content in a hidden holder so destroy() no longer throws.
- Use icon-list for the Unused tables tile (icon-th-list does not exist).
- Zero-date tile shows one status line: progress while unfinished, else relative time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only MySQL errno 1146/1054 and SQLSTATE 42S02/42S22/42P01/42703 now mean
"table or column gone" (MissingObjectException, original kept as
previous). Any other failure keeps the table's previous result, records
the table in the state's `error`, stops the batch and leaves the cursor
in place, so a lost connection can no longer complete a pass as an
all-clear.

Each table is now counted in one scan for all its date columns
(Catalog::zeroDateCounts). The scanner marks the table in progress and
hands the state to a callback before counting it; a run that finds the
marker on the cursor table skips that table as too large to check in
one request instead of dying on it forever.

MySQL dateColumns() lists base tables only, like tables(). The catalogs
use createQuery().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dashboard side of the scanner change:
- the zerodates task stores the state before each table, so a request
  that dies leaves its in-progress marker behind; it returns `error`,
  and Check now stops with a message instead of looping
- the zero-date tile names the table that could not be checked (never
  green then), counts tables too large to check in one request, and
  says "Last checked: <time>"; Details list both, and every Details
  popup ends with the next step for the maintainer
- a failing schema check returns a warning with the unavailable text
  instead of a healthy 0
- a stale unused-table list is shown as is and refreshed in the
  background by the admin script; only a missing list is built inline
- the zerodates and unused tasks close the session before scanning
- Check now says what it re-runs when only one check applies (e.g.
  PostgreSQL has no zero dates)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ignore names are now up to 255 characters of anything but control
characters (varchar(255) in supports.sql, the 6.2.0-2026-10-19 update
files and the test datasets). The old [A-Za-z0-9_$.]{1,128} rule left
hyphenated tables, literal `#__` tables and 64 + 1 + 64 character
table.column pairs with no Ignore button, a permanently yellow tile;
the names are always bound, so the strict charset bought no safety.

A column entry splits on the last dot (`a.b.c` is table `a.b`, column
`c`); a table entry may hold a dot; a prefix still ends with `_` and has
no dot. IgnoreRepository uses createQuery().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Core's DatabaseModel falls back to <base>/sql/updates/<driver> for
extensions whose manifest has no <update><schemas><schemapath>; tables
created only there were reported as unused. TableOwnership now reads
those folders too.

Also pins the line-start `#__` continuation case in SqlTableNamesTest
(`RENAME TABLE\n#__old TO #__new` is not a `#` comment).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
isTableIgnored() let a prefix entry silence any table starting with it,
which R3 forbids for the site's own tables; nothing used it any more.
The ignore list test now pins that a prefix entry is not a table entry.

Every method, constant and property docblock in the plugin, and the
test helpers, now has a description and @SInCE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ss Check now

The in-progress marker now carries its start time. A marker on the cursor
table younger than the longest a request may run (time budget or PHP's
time limit, 300 s when unlimited, plus 30 s) means another request is
counting it: the batch, even a restart, reports busy and stores nothing,
instead of recording a healthy table as too large. An older marker is a
dead request and the table is skipped as before.

Skipped tables keep the time they were skipped and survive a new pass
for the refresh hours, so Check now no longer restarts into the same
huge table and dies on it again. Any Throwable from a count is recorded
like a RuntimeException, so the marker never outlives a caught error.
Bare marker and skipped values cached by the previous shape are
tolerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A busy reply means another request is running the pass: wait 2 seconds
and ask again with restart=0, up to 30 times in a row, then stop with
the stalled message. The no-progress check applies to non-busy replies
only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Check now always opens with restart=1, and start() cleared the marker of
a request that had died, so the huge table was counted again and the
request died again, forever. start() now records the cursor table of a
dead marker (same dead-after rule as run()) in skipped before it resets
the pass. Note that the dead-after time is a heuristic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onses

The ignore table keeps the core utf8mb4_unicode_ci collation, under which
cafe_log equals café_log. exists() and remove() now fetch the
collation-equal rows and compare names in PHP, and remove() deletes by
primary key, so Reopen cafe_log no longer deletes café_log. When only a
collation-equal entry exists, add() refuses (ok false) instead of
claiming an entry it could not store. Names with a space at either end
are invalid (PAD SPACE).

A failed insert logs the driver message and throws a generic
RuntimeException, so com_ajax does not echo the database error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quoteName() splits on dots, so a zero-date count on column `c.d` or
table `x.y` queried `c`.`d` or another schema; the error then read as
"gone" and the table's findings were dropped, a false all-clear. The
MySQL catalog now quotes these identifiers as one part, and before the
scanner treats a missing-object error as a drop it asks the new
Catalog::tableExists() (bound values against information_schema). A
table that is still there is recorded as an error instead.

The driver's replacePrefix() rewrites #__ even inside a quoted
identifier, so a table or date column whose name holds #__ cannot be
counted safely. start() lists such tables in skipped with reason
"name" (rebuilt on every start, never counted) and drops their old
results. The tile and Details name them apart from the too-large ones,
text only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aces

The mysqli statement rewrites :name into ? even inside a backtick
identifier, so a table or date column such as jos_log:2020 failed as
an unknown column, was found to exist and stayed an error forever,
blocking every later table. Such names now go to skipped with reason
"name", like names holding #__.

Ignore names may again start or end with a space: MySQL allows a
leading one and PostgreSQL both, and the byte-exact comparison already
keeps a PAD SPACE match from being stored or deleted by mistake.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@obuisard obuisard changed the title [AI] [6.2] Health Check: database check [AI] [6.3] Health Check: database check Nov 11, 2026
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