feat: seamless auto-continue on Joomla Update after pre-update backup
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 20s
Generic: Project CI / Lint & Validate (pull_request) Has been cancelled
Universal: PR Check / Branch Policy (pull_request) Has been cancelled
Universal: PR Check / Require Docs Update (pull_request) Has been cancelled
Universal: PR Check / Wiki Update Reminder (pull_request) Has been cancelled
Universal: PR Check / Secret Scan (pull_request) Has been cancelled
Universal: PR Check / Validate PR (pull_request) Has been cancelled
Joomla: Metadata Validation / Validate Joomla Metadata (pull_request) Has been cancelled
Branch Cleanup / Delete merged branch (pull_request) Has been cancelled
RC Revert / Rename rc/ back to dev/ (pull_request) Has been cancelled
Generic: Project CI / Tests (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled

After the full-screen pre-update backup returns to the Joomla Update
confirm page (layout=update&is_backed_up=1), inject a small script that
ticks Joomla's 'I have taken a backup' checkbox (#joomlaupdate-confirm-
backup) and clicks the Install button (.emptystate-btnadd) so the update
continues automatically — no second manual click. Injected via
onBeforeCompileHead, super-user only, gated on backup_before_update.

Claude-Session: https://claude.ai/code/session_01WbGBN9VyRK61zczYWcCQ2i
This commit is contained in:
2026-07-12 15:50:23 -05:00
parent 1326ab3fc8
commit 59607a11cb
2 changed files with 44 additions and 0 deletions
+1
View File
@@ -3,6 +3,7 @@
## [Unreleased]
### Fixed
- Pre-update backup on the **Joomla Update** page is now **seamless** (Akeeba-style): after the full-screen backup runs, the plugin auto-ticks Joomla's "I have taken a backup" checkbox and clicks Install, so the update continues automatically instead of stopping for a second manual click.
- Pre-update full-screen backup now actually fires on the **Joomla Update** page. The "Install the update" button posts to `option=com_joomlaupdate&layout=update` (Joomla's confirm/updating page) — carrying **only `layout=update`**, no `view`/`task` — so the previous match on `view=update`/`update.install` never triggered. The plugin now intercepts `layout=update` (as well as `view=update` and the legacy `update.install`) and returns the browser there flagged `is_backed_up=1`.
### Added
@@ -170,6 +170,25 @@ final class MokoSuiteBackup extends CMSPlugin implements SubscriberInterface
$input = $app->getInput();
// Joomla core update: after the pre-update backup returns to the confirm
// page (layout=update&is_backed_up=1), auto-check Joomla's "I have a
// backup" box and click Install so the update continues seamlessly
// (Akeeba-style) instead of stopping for a second manual click.
if ($input->getCmd('option', '') === 'com_joomlaupdate') {
if ($input->getCmd('layout', '') === 'update'
&& (int) ComponentHelper::getParams('com_mokosuitebackup')->get('backup_before_update', 0)) {
$user = $app->getIdentity();
$doc = $app->getDocument();
if ($user && !$user->guest && $user->authorise('core.admin') && $doc instanceof HtmlDocument) {
$doc->getWebAssetManager()->useScript('core');
$doc->addScriptDeclaration($this->joomlaUpdateAutoContinueScript());
}
}
return;
}
if ($input->getCmd('option', '') !== 'com_installer') {
return;
}
@@ -226,6 +245,30 @@ final class MokoSuiteBackup extends CMSPlugin implements SubscriberInterface
$doc->addScript(Uri::root(true) . '/media/plg_system_mokosuitebackup/js/installer-backup.js', [], ['defer' => true]);
}
/**
* Inline JS for the Joomla Update confirm page. When we return there after
* the pre-update backup (is_backed_up=1), it ticks Joomla's "I have taken a
* backup" checkbox and clicks the Install button (.emptystate-btnadd) so the
* update proceeds automatically — seamless, no second manual click.
*/
private function joomlaUpdateAutoContinueScript(): string
{
return <<<'JS'
(function () {
'use strict';
if (new URLSearchParams(window.location.search).get('is_backed_up') !== '1') { return; }
var go = function () {
var chk = document.getElementById('joomlaupdate-confirm-backup');
var wrap = document.getElementById('joomlaupdate-wrapper');
var btn = (wrap && wrap.querySelector('.emptystate-btnadd')) || document.querySelector('.emptystate-btnadd');
if (chk) { chk.checked = true; chk.dispatchEvent(new Event('change', { bubbles: true })); }
if (btn) { btn.classList.remove('disabled'); window.setTimeout(function () { btn.click(); }, 400); }
};
if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', go); } else { go(); }
})();
JS;
}
/**
* Send a Joomla core update through the full-screen backup page BEFORE the
* update applies (Akeeba-style), so no backup runs synchronously inside the