diff --git a/.coderabbit.yaml b/.coderabbit.yaml
index 24006ece..ad04c22e 100644
--- a/.coderabbit.yaml
+++ b/.coderabbit.yaml
@@ -206,6 +206,54 @@ reviews:
GraphQL checks in schema.py; flag a second copy of either.
- TESTS use synthetic versions, shas and handles only; a value captured
from a live system in a fixture is a finding.
+ - path: ".github/unraid-compat/**"
+ instructions: |
+ The Unraid compatibility matrix; CI only, nothing here ships.
+ - install_test.sh puts the .plg through each Unraid version's own
+ plugin installer, hooks included, in a fresh Docker container with
+ no network; it must refuse to run anywhere else (lib.sh's guard).
+ Only Slackware's upgradepkg and removepkg are stubbed, keeping their
+ file-list records: flag any other stand-in for Unraid's code.
+ - fake_unraid.sh serves one Unraid version's real webGUI with php -S
+ and pages_test.php drives FV3 through it. Stand-ins are what the OS
+ image adds around the webGUI, nothing of the webGUI itself:
+ router.php (nginx's locations), prepend.php (php.ini's prepend),
+ docker.php (dockerd's socket and the docker CLI), libvirt.php (the
+ php-libvirt extension), rc_service.sh (rc.docker and rc.libvirt),
+ dmidecode.sh and ip.sh (those commands), connect_state.php (the
+ Connect plugin), the dockerd and libvirtd
+ processes, and emhttp's state files (var.ini, network.ini, the
+ docker and domain cfg). A call a stand-in does not answer fails
+ the run: flag an answer that hides one, and any stand-in for code
+ the webGUI repo has.
+ - browser_test.sh starts fake_unraid.sh in a container with no network
+ and runs the Playwright image in a second container that joins its
+ network. browser_test.js drives FV3's Docker, VMs and Dashboard
+ pages in Chromium and Firefox and checks what the user sees (rows,
+ tiles, an opened folder, the advanced preview's layout) against
+ values written by hand. A failed request or console error passes
+ only for a service the fake does not run (ABSENT) or for Unraid's
+ own unload handler. Clicks are a user's; only where an element of
+ Unraid's page frame named in FRAME covers the target is the click
+ dispatched instead.
+ fake_logs.php holds the log checks both tests run. package.json
+ pins playwright-core to the image's version, which
+ browser_test.sh checks.
+ - browser_test.sh runs an Unraid-alone pass first, FV3's three
+ page hooks moved out of its plugin folder. It checks hooks.js, a
+ hand-written list of Unraid's DOM hooks, functions, stylesheet
+ classes and endpoints FV3 relies on, each naming the FV3 file that
+ still mentions it and what the user loses; any/since only where
+ FV3 itself branches.
+ layout.js holds the layout rules FV3's pass checks against that
+ pass and a loose container on the same page, each from a fix FV3
+ has shipped.
+ - matrix_check.py keeps ci.yml's Unraid rows at one per minor from the
+ .plg's min to the newest release; Renovate only moves rows.
+ - Each step asserts what the user is left with (live files, the
+ registered manifest, saved folders, Unraid's orders) right after it,
+ against values written by hand. A failed step fails the job.
+ - Fixtures hold synthetic names and ids only.
- path: ".github/scripts/**"
instructions: |
CI tests and helpers; nothing here ships in the plugin.
@@ -224,6 +272,9 @@ reviews:
failed read or download as "nothing to report".
- package.json here is test-only (jquery, jsdom), pinned to exact
versions.
+ - php_tests.sh is the one list of PHP checks for Lint + build and the
+ PHP matrix: php -l on every .php and .page file, then every
+ *_test.php here; a deprecation fails like an error.
- path: "**"
instructions: |-
Applies to every file, whatever the language:
diff --git a/.github/scripts/action_refusal_test.js b/.github/scripts/action_refusal_test.js
new file mode 100644
index 00000000..6f546c51
--- /dev/null
+++ b/.github/scripts/action_refusal_test.js
@@ -0,0 +1,114 @@
+// node .github/scripts/action_refusal_test.js — a folder action Unraid refuses shows Unraid's own reason: the real docker.js and vm.js
+// folder actions and shared.js, answered as Unraid's Events.php ({success: true|reason}) and VMajax.php ({success: true}|{error: reason}) answer
+'use strict';
+const { drawDocker, drawVms, check, done, FOLDER_SETTINGS } = require('./preview_pages_harness.js');
+
+const folder = (name, containers = [], regex = '') => ({ name, containers, regex });
+// A VM folder as vm.json holds one
+const vmFolder = (name, vms) => ({ name, icon: '', regex: '', containers: vms, settings: { ...FOLDER_SETTINGS }, hidden_preview: [], actions: [] });
+
+// Each action post answered by `answer(data)` (or failed when it returns an Error); the dialogs as the user reads them
+const stub = (p, answer) => {
+ const posts = [];
+ const dialogs = [];
+ p.$.post = (url, data) => {
+ posts.push({ url, data });
+ const a = answer(data);
+ return a instanceof Error ? p.$.Deferred().reject({ status: 500, statusText: a.message }) : p.$.Deferred().resolve(a);
+ };
+ p.w.swal = (o) => {
+ const box = p.w.document.createElement('div');
+ box.innerHTML = String(o.text);
+ dialogs.push({ title: o.title, lines: box.innerHTML.split(' ').map((part) => { box.innerHTML = part; return box.textContent; }) });
+ };
+ p.w.swal.close = () => {};
+ return { posts, dialogs };
+};
+
+// Runs a folder action to the end on the page's manual clock
+const act = async (p, call) => {
+ let finished = false;
+ p.g(call).then(() => { finished = true; }, (e) => { p.errors.push(`${call}: ${e && e.stack || e}`); finished = true; });
+ for (let i = 0; i < 50 && !finished; i++) await p.tick(100);
+ return finished;
+};
+
+(async () => {
+ const REFUSED = 'Error response from daemon: cannot stop container: web: permission denied';
+ {
+ const page = await drawDocker({ folders: { f: folder('Apps', ['web', 'db']) }, containers: ['web', 'db'], prefs: ['folder-f', 'web', 'db'] });
+ await page.draw();
+ const { posts, dialogs } = stub(page.p, (data) => (data.container === page.p.g("globalFolders['f'].containers['web'].id") ? { success: REFUSED } : { success: true }));
+ const finished = await act(page.p, "actionFolder('f', 'stop')");
+ check("a container Unraid refuses to stop: the dialog shows Unraid's reason, not its JSON answer",
+ finished && posts.length === 2 && dialogs.length === 1 && dialogs[0].title === 'exec-error' && JSON.stringify(dialogs[0].lines) === JSON.stringify([REFUSED]),
+ { finished, posts: posts.length, dialogs, errors: page.p.errors });
+ }
+ {
+ const page = await drawDocker({ folders: { f: folder('Apps', ['web', 'db']) }, containers: ['web', 'db'], prefs: ['folder-f', 'web', 'db'] });
+ await page.draw();
+ const { posts, dialogs } = stub(page.p, () => ({ success: true }));
+ const finished = await act(page.p, "actionFolder('f', 'stop')");
+ check('every container accepted: no dialog', finished && posts.length === 2 && dialogs.length === 0, { finished, posts: posts.length, dialogs });
+ }
+ {
+ const page = await drawDocker({ folders: { f: folder('Apps', ['web']) }, containers: ['web'], prefs: ['folder-f', 'web'] });
+ await page.draw();
+ const { dialogs } = stub(page.p, () => new Error('Internal Server Error'));
+ const finished = await act(page.p, "actionFolder('f', 'stop')");
+ check('a request that fails outright is still in the dialog, named by its failure',
+ finished && dialogs.length === 1 && JSON.stringify(dialogs[0].lines) === JSON.stringify(['Internal Server Error']), { finished, dialogs });
+ }
+ {
+ const NO_NETWORK = "Requested operation is not valid: network 'br0' is not active";
+ const p = await drawVms({ folders: { v: vmFolder('VMs', ['vm-a', 'vm-b']) }, names: ['vm-a', 'vm-b'], prefs: ['folder-v', 'vm-a', 'vm-b'] });
+ const { posts, dialogs } = stub(p, (data) => (data.uuid === 'u0' ? { error: NO_NETWORK } : { success: true, state: 'running' }));
+ const finished = await act(p, "actionFolder('v', 'domain-start')");
+ check("a VM Unraid refuses to start: the dialog shows libvirt's reason, not the JSON answer",
+ finished && posts.length === 2 && dialogs.length === 1 && JSON.stringify(dialogs[0].lines) === JSON.stringify([NO_NETWORK]),
+ { finished, posts: posts.length, dialogs, errors: p.errors });
+ }
+ {
+ // A success that also carries an `error` field (a warning) is still a success
+ const p = await drawVms({ folders: { v: vmFolder('VMs', ['vm-a']) }, names: ['vm-a'], prefs: ['folder-v', 'vm-a'] });
+ const { dialogs } = stub(p, () => ({ success: true, state: 'running', error: 'Waiting for the guest agent' }));
+ const finished = await act(p, "actionFolder('v', 'domain-start')");
+ check('an answer that says success and also carries an error field is a success: no dialog', finished && dialogs.length === 0, { finished, dialogs });
+ }
+ {
+ // json_encode of nothing: the action still ends with a dialog instead of throwing with the spinner up
+ const page = await drawDocker({ folders: { f: folder('Apps', ['web']) }, containers: ['web'], prefs: ['folder-f', 'web'] });
+ await page.draw();
+ const { dialogs } = stub(page.p, () => null);
+ const finished = await act(page.p, "actionFolder('f', 'stop')");
+ check('a null answer ends the action with a dialog that says the request failed',
+ finished && !page.p.errors.length && dialogs.length === 1 && JSON.stringify(dialogs[0].lines) === JSON.stringify(['Request failed']), { finished, dialogs, errors: page.p.errors });
+ }
+ {
+ // With the Unraid API (7.2 and later) the action goes to GraphQL first; when that errors, the PHP endpoint's refusal is shown
+ const page = await drawDocker({ folders: { f: folder('Apps', ['web']) }, containers: ['web'], prefs: ['folder-f', 'web'], api: true });
+ await page.draw();
+ const realFetch = page.p.w.fetch;
+ let mutations = 0;
+ page.p.w.fetch = async (url, init) => {
+ if (!String(url).includes('/graphql') || !/mutation/.test(String(init && init.body))) return realFetch(url, init);
+ mutations++;
+ return { ok: true, json: async () => ({ errors: [{ message: 'container web: permission denied' }] }) };
+ };
+ const { posts, dialogs } = stub(page.p, () => ({ success: REFUSED }));
+ const finished = await act(page.p, "actionFolder('f', 'stop')");
+ check("with the API, an action GraphQL refuses goes to Unraid's PHP endpoint once, and its reason is shown",
+ finished && mutations === 1 && posts.length === 1 && dialogs.length === 1 && JSON.stringify(dialogs[0].lines) === JSON.stringify([REFUSED]),
+ { finished, mutations, posts: posts.length, dialogs, errors: page.p.errors });
+ }
+ {
+ // An answer with no reason in it is still a failure, shown as Unraid sent it
+ const page = await drawDocker({ folders: { f: folder('Apps', ['web']) }, containers: ['web'], prefs: ['folder-f', 'web'] });
+ await page.draw();
+ const { dialogs } = stub(page.p, () => ({ success: '' }));
+ const finished = await act(page.p, "actionFolder('f', 'stop')");
+ check('an Events.php answer with an empty reason is a failure, not a success',
+ finished && dialogs.length === 1 && JSON.stringify(dialogs[0].lines) === JSON.stringify(['{"success":""}']), { finished, dialogs });
+ }
+ done();
+})().catch((e) => { console.error(e); process.exit(1); });
diff --git a/.github/scripts/docker_saved_places_test.js b/.github/scripts/docker_saved_places_test.js
index 1a28436a..96ec7187 100644
--- a/.github/scripts/docker_saved_places_test.js
+++ b/.github/scripts/docker_saved_places_test.js
@@ -1,7 +1,9 @@
-// node .github/scripts/docker_saved_places_test.js — a deleted folder or removed container still named in userprefs.cfg no longer
-// moves a saved folder on the Docker page (npm ci in this folder first)
+// node .github/scripts/docker_saved_places_test.js — where the Docker page puts saved folders: stale userprefs.cfg entries do not move
+// them, and after sync_order.php (asked for once per load) regroups the file, the page draws its rows in its order (npm ci here first)
'use strict';
-const { drawDocker, check, done } = require('./preview_pages_harness.js');
+const fs = require('fs');
+const path = require('path');
+const { drawDocker, phpServer, check, done } = require('./preview_pages_harness.js');
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
const folder = (name, containers = [], regex = '') => ({ name, containers, regex });
@@ -65,5 +67,121 @@ const folder = (name, containers = [], regex = '') => ({ name, containers, regex
check('the generated orders do place folders, with and without unsaved rows above them', shapes.folders > 50 && shapes.unsaved > 50 && shapes.both > 20, shapes);
check('200 generated orders with nothing stale place every folder where they did before', differ.length === 0, differ.slice(0, 2));
}
+ // The real sync_order.php on a saved userprefs.cfg: its answers, the file after one sync, and after a second
+ const synced = (folders, containers, prefs) => {
+ const php = phpServer('userprefs-sync', { containers });
+ try {
+ const dockerMan = path.join(path.dirname(php.config), 'dockerMan');
+ const file = path.join(dockerMan, 'userprefs.cfg');
+ fs.writeFileSync(path.join(php.config, 'docker.json'), JSON.stringify(folders));
+ fs.writeFileSync(path.join(dockerMan, 'dockerMan.cfg'), `autostart-file="${path.join(dockerMan, 'unraid-autostart')}"\n`);
+ fs.writeFileSync(file, prefs.map((n, i) => `${i}="${n}"\n`).join(''));
+ const read = () => fs.readFileSync(file, 'utf8').split('\n').filter(Boolean).map((l) => l.replace(/^\d+="(.*)"$/, '$1'));
+ const first = php.server('sync_order.php', 'POST', { type: 'docker' });
+ const after = read();
+ return { answers: [first, php.server('sync_order.php', 'POST', { type: 'docker' })], after, again: read() };
+ } finally { php.cleanup(); }
+ };
+ const drawnFrom = async (folders, containers, prefs) => { const page = await drawDocker({ folders, containers, prefs }); await page.draw(); return page; };
+ for (const [what, folders, containers, prefs] of [
+ ['a folder member it lacks', { f: folder('F', ['x', 'y']) }, ['a', 'b', 'x', 'y'], ['a', 'folder-f', 'x', 'b']],
+ ['a member saved away from its folder', { f: folder('F', ['x', 'y']) }, ['a', 'b', 'x', 'y'], ['y', 'a', 'folder-f', 'x', 'b']],
+ ['a member moved to another folder', { f: folder('F', ['x']), g: folder('G', ['w', 'y']) }, ['w', 'x', 'y'], ['folder-f', 'x', 'y', 'folder-g', 'w']],
+ ['members saved before their folder', { f: folder('F', ['x', 'y']) }, ['a', 'x', 'y'], ['x', 'folder-f', 'a']],
+ ['a regex folder', { r: folder('Rx', [], '^web') }, ['web1', 'web2', 'db'], ['web2', 'folder-r', 'db', 'web1']],
+ ]) {
+ const r = synced(folders, containers, prefs);
+ const [was, now] = [(await drawnFrom(folders, containers, prefs)).drawn(), (await drawnFrom(folders, containers, r.after)).drawn()];
+ check(`${what}: the sync regroups userprefs.cfg, and the page draws the same from it`, r.answers[0] === '{"success":true}' && !same(r.after, prefs) && same(was, now), { answers: r.answers, after: r.after, was, now });
+ }
+ {
+ // A regex folder saved while empty; web1, installed since, joins it by regex
+ const r = synced({ f: folder('F', [], '^web') }, ['a', 'web1', 'b'], ['a', 'folder-f', 'b']);
+ check('a folder with none of its members saved yet gets them after its entry', same(r.after, ['a', 'folder-f', 'web1', 'b']), r);
+ }
+ // The real read_membership.php: container => folder name. `json` is docker.json as written, its key order kept
+ const membershipOf = (folders, containers, prefs, json = JSON.stringify(folders)) => {
+ const php = phpServer('membership', { containers });
+ try {
+ fs.writeFileSync(path.join(php.config, 'docker.json'), json);
+ if (prefs.length) fs.writeFileSync(path.join(path.dirname(php.config), 'dockerMan', 'userprefs.cfg'), prefs.map((n, i) => `${i}="${n}"\n`).join(''));
+ return JSON.parse(php.server('read_membership.php', 'GET', { type: 'docker' })).membership;
+ } finally { php.cleanup(); }
+ };
+ {
+ const web = (name) => folder(name, [], '^web');
+ for (const [what, folders, containers, prefs, owner, json] of [
+ ['the folder userprefs.cfg names first', { a: web('A'), b: web('B') }, ['web1', 'loose'], ['folder-b', 'loose', 'folder-a'], 'b'],
+ ['of folders it does not name, an index-like id first', { x: web('X'), 7: web('Seven') }, ['web1', 'loose'], ['loose'], '7',
+ `{"x":${JSON.stringify(web('X'))},"7":${JSON.stringify(web('Seven'))}}`],
+ ['with nothing saved, the folder first A-Z', { z: web('Zulu'), a: web('Alpha') }, ['web1'], [], 'a'],
+ ]) {
+ const page = await drawnFrom(folders, containers, prefs);
+ const map = membershipOf(folders, containers, prefs, json);
+ check(`two folders' regexes match a container: ${what} gets it, on the page and in read_membership.php`,
+ same(page.members(owner), ['web1']) && map?.web1 === folders[owner].name, { members: Object.keys(folders).map((id) => [id, page.members(id)]), map });
+ }
+ const r = synced({ a: web('A'), b: web('B') }, ['web1', 'loose'], ['folder-b', 'loose', 'folder-a', 'web1']);
+ check('and the sync moves it beside the folder the page draws it in', same(r.after, ['folder-b', 'web1', 'loose', 'folder-a']), r);
+ }
+ {
+ // Generated folders (a container listed in one folder at most) and saved orders, with stale and unsaved entries
+ let seed = 20261116;
+ const rnd = (n) => { seed = (Math.imul(seed, 1103515245) + 12345) & 0x7fffffff; return (seed >>> 8) % n; };
+ const shuffle = (a) => { for (let i = a.length - 1; i > 0; i--) { const j = rnd(i + 1); [a[i], a[j]] = [a[j], a[i]]; } return a; };
+ const off = [], apart = [], unstable = [], refused = [];
+ let changed = 0, overlaps = 0;
+ for (let n = 0; n < 120; n++) {
+ const containers = shuffle(['a', 'b', 'c', 'web1', 'web2', 'x', 'y']).slice(0, 3 + rnd(5));
+ const nf = 1 + rnd(3);
+ const folders = Object.fromEntries(Array.from({ length: nf }, (_, i) => [`f${i}`, folder(`F${i}`, [], rnd(3) === 0 ? '^web' : '')]));
+ for (const c of containers) { const i = rnd(nf * 2); if (i < nf) folders[`f${i}`].containers.push(c); }
+ const entries = containers.concat(Object.keys(folders).map((k) => `folder-${k}`));
+ if (rnd(4) === 0) entries.push('ghost');
+ const prefs = shuffle(entries).filter(() => rnd(5) > 0);
+ if (!prefs.length) continue;
+ overlaps += Object.values(folders).filter((f) => f.regex).length > 1 && containers.some((c) => c.startsWith('web'));
+ const r = synced(folders, containers, prefs);
+ if (r.answers.some((a) => a !== '{"success":true}')) { refused.push({ folders, prefs, r }); continue; }
+ changed += !same(r.after, prefs);
+ if (!same(r.after, r.again)) unstable.push({ folders, containers, prefs, r });
+ const page = await drawnFrom(folders, containers, r.after);
+ const inFolder = new Set(Object.keys(folders).flatMap((id) => page.members(id)));
+ const shown = (e) => (e.startsWith('folder-') && folders[e.slice(7)]) || (containers.includes(e) && !inFolder.has(e));
+ // Unraid puts a name the file lacks first; docker.js puts each folder it lacks on top, the last in docker.json first
+ const want = Object.keys(folders).map((id) => `folder-${id}`).filter((e) => !r.after.includes(e)).reverse()
+ .concat(containers.filter((c) => !r.after.includes(c) && !inFolder.has(c)), r.after.filter(shown));
+ if (!same(page.rows(), want)) off.push({ folders, containers, after: r.after, rows: page.rows(), want });
+ // Members of a folder the file has no entry for stay where they were saved
+ const unsaved = new Set(Object.keys(folders).filter((id) => !r.after.includes(`folder-${id}`)).flatMap((id) => page.members(id)));
+ const named = r.after.filter((e) => containers.includes(e) && !unsaved.has(e));
+ if (!same(named, page.drawn().filter((e) => named.includes(e)))) apart.push({ folders, containers, after: r.after, drawn: page.drawn() });
+ }
+ check('the sync regroups over a quarter of the generated orders, and every sync answers success', changed > 30 && refused.length === 0, { changed, refused: refused.slice(0, 2) });
+ check('a second sync leaves userprefs.cfg as the first wrote it', unstable.length === 0, unstable.slice(0, 2));
+ check('after the sync the page draws its rows in the order userprefs.cfg names them', off.length === 0, { count: off.length, first: off.slice(0, 2) });
+ check('and userprefs.cfg names its containers in the order the page draws them, folders whose regexes match one container among them',
+ apart.length === 0 && overlaps > 10, { overlaps, count: apart.length, first: apart.slice(0, 2) });
+ }
+ {
+ const syncs = (page) => page.posts.filter((r) => r.url.endsWith('/sync_order.php')).map((r) => r.data);
+ const saved = { folders: { f: folder('F', ['m']) }, containers: ['a', 'm'], prefs: ['folder-f', 'a'] };
+ const page = await drawDocker(saved);
+ await page.draw();
+ await page.draw();
+ check('a page with folders and a saved order asks for one sync, not one per list rebuild', same(syncs(page), [{ type: 'docker' }]), page.posts);
+ for (const [what, setup] of [['nothing saved', { ...saved, prefs: [] }], ['no folders', { ...saved, folders: {} }],
+ ['no folder holds a container', { ...saved, containers: ['a'] }]]) {
+ const quiet = await drawDocker(setup);
+ await quiet.draw();
+ check(`${what}: no sync is asked for`, syncs(quiet).length === 0, quiet.posts);
+ }
+ const refused = await drawDocker(saved);
+ const banners = [];
+ refused.p.w.fv3ShowBanner = (text) => { banners.push(text); };
+ refused.failing.add('sync_order.php');
+ await refused.draw();
+ check('a refused sync shows the start-order banner with the reason', same(banners, ['The Docker start order could not be updated: refused by the test']), banners);
+ }
done();
})();
diff --git a/.github/scripts/error_handler_test.php b/.github/scripts/error_handler_test.php
new file mode 100644
index 00000000..a7ed48e5
--- /dev/null
+++ b/.github/scripts/error_handler_test.php
@@ -0,0 +1,52 @@
+&1', $out, $rc);
+check('the plugin was copied', $rc === 0 && is_file("$docroot/plugins/folder.view3/server/lib.php"), $out);
+// Each warns on its line 2: an FV3 file, Unraid's VM code, and a folder whose name only starts like FV3's
+$warns = [
+ 'fv3-own' => "$docroot/plugins/folder.view3/server/fv3t_warn.php",
+ 'unraid-own' => "$docroot/plugins/dynamix.vm.manager/include/fv3t_warn.php",
+ 'name-prefix' => "$docroot/plugins/folder.view3-copy/fv3t_warn.php",
+];
+// lib.php requires these two Unraid host files at load time
+$files = ['webGui/include/Helpers.php' => ' ' $path) $files[substr($path, strlen("$docroot/"))] = " $src) {
+ @mkdir(dirname("$docroot/$rel"), 0777, true);
+ file_put_contents("$docroot/$rel", $src);
+}
+
+// A process of its own, as an endpoint request runs: lib.php's handler and the log settings stay out of this test's PHP
+$request = '$_SERVER["DOCUMENT_ROOT"] = ' . var_export($docroot, true) . '; require ' . var_export("$docroot/plugins/folder.view3/server/lib.php", true) . ';'
+ . ' $configDir = ' . var_export("$fv3tTmp/config", true) . '; foreach (' . var_export(array_values($warns), true) . ' as $f) include $f;';
+$out = [];
+exec(escapeshellarg(PHP_BINARY) . ' -d error_reporting=-1 -d display_errors=0 -d log_errors=1 -d error_log=' . escapeshellarg("$fv3tTmp/php.log")
+ . ' -r ' . escapeshellarg($request) . ' 2>&1', $out, $rc);
+check('the request ran with no output', $rc === 0 && $out === [], ['rc' => $rc, 'out' => $out]);
+
+$logged = @file("$fv3tTmp/config/error.log", FILE_IGNORE_NEW_LINES) ?: [];
+check("error.log holds the FV3 file's warning and nothing else",
+ count($logged) === 1 && preg_match('/^\[\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\] php-error: Undefined array key "fv3-own" at fv3t_warn\.php:2$/', $logged[0]), $logged);
+$phplog = (string)@file_get_contents("$fv3tTmp/php.log");
+foreach ($warns as $key => $path) {
+ check("PHP's own log still has the $key warning", str_contains($phplog, "PHP Warning: Undefined array key \"$key\" in $path on line 2"), $phplog);
+}
+
+exec('rm -rf ' . escapeshellarg($fv3tTmp));
+echo $fv3tFailed ? "\n$fv3tFailed FAILED\n" : "\nall passed\n";
+exit($fv3tFailed ? 1 : 0);
diff --git a/.github/scripts/important_check.py b/.github/scripts/important_check.py
new file mode 100644
index 00000000..489c0fd1
--- /dev/null
+++ b/.github/scripts/important_check.py
@@ -0,0 +1,132 @@
+#!/usr/bin/env python3
+"""Each !important in the plugin's own CSS, JS, PHP and .page files needs a `!important: ` comment."""
+import pathlib
+import re
+import sys
+
+import vendor
+
+REASON = re.compile(r'!important:\s*\w', re.I)
+KINDS = {'.css': 'css', '.js': 'js', '.php': 'php', '.page': 'page'}
+# A `/` after one of these, or first on its line, opens a JS regex literal rather than dividing; not `<`, as `
` has it
+REGEX_AFTER = set('(,=:[!&|?{};+-*%>~^')
+
+
+def _blank(code, text, i, j):
+ code[i:j] = [ch if ch == '\n' else ' ' for ch in text[i:j]]
+
+
+def _regex_end(text, i):
+ """End of the JS regex literal opening at `i`, or None when the `/` divides."""
+ before = text[:i].rstrip(' \t')
+ if before and not before.endswith('\n') and before[-1] not in REGEX_AFTER and not re.search(r'\b(return|typeof)$', before):
+ return None
+ j, in_class = i + 1, False
+ while j < len(text) and text[j] != '\n':
+ if text[j] == '\\':
+ j += 1
+ elif text[j] == '[':
+ in_class = True
+ elif text[j] == ']':
+ in_class = False
+ elif text[j] == '/' and not in_class:
+ return j + 1
+ j += 1
+ return None
+
+
+def _in_script(spans, i):
+ return any(start <= i < end for start, end in spans)
+
+
+def scan(text, kind):
+ """(code, comments): the text with comments, CSS strings and JS regexes blanked, and [(start, end, comment text)]."""
+ code, comments, i, n = list(text), [], 0, len(text)
+ script = kind != 'css'
+ # A .page holds CSS and HTML too: only its ', text, re.I | re.S)] if kind == 'page' else []
+ slashes = [(0, n)] if kind in ('js', 'php') else js + [m.span(1) for m in re.finditer(r'<\?(.*?)(?:\?>|\Z)', text, re.S)] if kind == 'page' else []
+ while i < n:
+ c, two = text[i], text[i:i + 2]
+ html = kind == 'page' and text.startswith('' if html else '\n'
+ found = text.find(close, i + 2)
+ end = n if found == -1 else found + (0 if close == '\n' else len(close))
+ comments.append((i, end, text[i:end]))
+ _blank(code, text, i, end)
+ i = end
+ elif c == '/' and _in_script(js, i) and (end := _regex_end(text, i)):
+ _blank(code, text, i, end)
+ i = end
+ elif c in '"\'' or (c == '`' and script):
+ j = i + 1
+ while j < n and text[j] != c and text[j] != '\n':
+ j += 2 if text[j] == '\\' else 1
+ # A script's string is where inline styles live: keep it as code; a CSS string (content: "...") is text
+ if kind == 'css':
+ _blank(code, text, i, j + 1)
+ i = j + 1
+ else:
+ i += 1
+ return ''.join(code), comments
+
+
+def _line(text, at):
+ return text.count('\n', 0, at)
+
+
+def _own_line(text, start):
+ return text[text.rfind('\n', 0, start) + 1:start].strip() == ''
+
+
+def _reason(comments, text, line, alone):
+ """A reason comment ending on `line`; with `alone`, only one with no code before it on its line."""
+ return any(REASON.search(body) and _line(text, end - 1) == line and (not alone or _own_line(text, start))
+ for start, end, body in comments)
+
+
+def _rule_start(code, at):
+ """Where the selector of the rule holding the declaration at `at` begins, past any nested rules; None outside a rule."""
+ depth, opened = 0, at - 1
+ while opened >= 0 and not (code[opened] == '{' and depth == 0):
+ depth += (code[opened] == '}') - (code[opened] == '{')
+ opened -= 1
+ if opened < 0:
+ return None
+ start = max(code.rfind(ch, 0, opened) for ch in '{};') + 1
+ while start < opened and code[start].isspace():
+ start += 1
+ return start
+
+
+def problems_in(path, text, kind):
+ code, comments = scan(text, kind)
+ out = []
+ for m in re.finditer(r'!\s*important\b', code, re.I):
+ line = _line(text, m.start())
+ ok = _reason(comments, text, line, alone=False) or _reason(comments, text, line - 1, alone=True)
+ start = _rule_start(code, m.start()) if kind == 'css' else None
+ if not ok and start is not None:
+ ok = _reason(comments, text, _line(text, start) - 1, alone=True) or _reason(comments, text, _line(text, start), alone=True)
+ if not ok:
+ out.append(f'{path}:{line + 1}: !important without a "!important: " comment on its line, the line above, or above its rule')
+ return out
+
+
+def problems(repo):
+ repo = repo.resolve()
+ manifest, root = vendor.plugin_root(repo)
+ bundled = {vendor.destination(manifest, root, dest) for lib in manifest['libraries'] for dest in lib['files'].values()}
+ files = [p for p in sorted(root.rglob('*')) if p.suffix in KINDS and p.is_file() and p.resolve() not in bundled]
+ if not files:
+ return [f'{manifest["root"]}: no CSS, JS, PHP or .page files to check']
+ return [problem for p in files for problem in problems_in(p.relative_to(repo), p.read_text(encoding='utf-8'), KINDS[p.suffix])]
+
+
+if __name__ == '__main__':
+ found = problems(pathlib.Path(__file__).resolve().parents[2])
+ print('\n'.join(found) or 'Every !important has its reason')
+ sys.exit(1 if found else 0)
diff --git a/.github/scripts/important_check_test.py b/.github/scripts/important_check_test.py
new file mode 100644
index 00000000..ad451f49
--- /dev/null
+++ b/.github/scripts/important_check_test.py
@@ -0,0 +1,98 @@
+import json
+import pathlib
+import tempfile
+import unittest
+
+import important_check
+
+ROOT = 'src/plugin'
+
+
+class ImportantCheckTest(unittest.TestCase):
+ def check(self, files, bundled=()):
+ tmp = tempfile.TemporaryDirectory()
+ self.addCleanup(tmp.cleanup)
+ repo = pathlib.Path(tmp.name)
+ (repo / 'vendor.json').write_text(json.dumps({'root': ROOT, 'libraries': [{'files': {f'x/{b}': b for b in bundled}}]}), encoding='utf-8')
+ for name, text in files.items():
+ (repo / ROOT / name).parent.mkdir(parents=True, exist_ok=True)
+ (repo / ROOT / name).write_text(text, encoding='utf-8')
+ return important_check.problems(repo)
+
+ def test_a_reason_above_the_rule_or_on_the_line_passes(self):
+ sheet = ('.a { top: 0 }\n\n/* !important: Unraid inlines this padding */\n#t .x,\n#t .y {\n padding-left: 20px !important;\n}\n'
+ '.b { margin: 0 !important; /* !important: a theme sets it inline */ }\n')
+ self.assertEqual(self.check({'styles/a.css': sheet}), [])
+
+ def test_an_important_without_its_reason_is_named_with_its_line(self):
+ sheet = '/* spacing */\n.a {\n top: 0;\n left: 1px!important;\n}\n'
+ self.assertEqual(self.check({'styles/a.css': sheet}),
+ [f'{ROOT}/styles/a.css:4: !important without a "!important: " comment on its line, the line above, or above its rule'])
+
+ def test_a_reason_belongs_to_the_rule_under_it_only(self):
+ sheet = '/* !important: first */\n.a { top: 0 !important }\n.b { top: 0 !important }\n'
+ (problem,) = self.check({'styles/a.css': sheet})
+ self.assertIn('a.css:3:', problem)
+
+ def test_a_reason_at_the_end_of_a_line_covers_that_line_only(self):
+ rules = '.a { top: 0 !important } /* !important: r */\n.b { top: 0 !important }\n'
+ decls = '.c {\n top: 0 !important; /* !important: r */\n left: 0 !important;\n}\n'
+ self.assertEqual([p.split(': !')[0] for p in self.check({'styles/a.css': rules, 'styles/b.css': decls})],
+ [f'{ROOT}/styles/a.css:2', f'{ROOT}/styles/b.css:3'])
+
+ def test_a_nested_rule_does_not_move_a_declaration_to_its_selector(self):
+ outer = '/* !important: r */\n.a {\n .b { color: red }\n top: 0 !important;\n}\n'
+ inner = '.a {\n /* !important: r */\n .b { color: red }\n top: 0 !important;\n}\n'
+ self.assertEqual(self.check({'styles/a.css': outer}), [])
+ (problem,) = self.check({'styles/b.css': inner})
+ self.assertIn('b.css:4:', problem)
+
+ def test_a_quote_in_a_regex_literal_or_a_php_hash_comment_is_read_as_code_does(self):
+ js = "s = s.replace(/'/g, ''); el.style.cssText = 'x:1 !important'; // !important: r\n"
+ php = "See https://example.test\n\n\n'})
+ self.assertEqual([p.split(': !')[0] for p in found], [f'{ROOT}/Folder.page:1', f'{ROOT}/styles/a.css:1'])
+
+ def test_a_url_in_page_css_is_no_regex_but_one_in_its_script_is(self):
+ page = ('\n'
+ "\n")
+ (problem,) = self.check({'Folder.page': page})
+ self.assertIn('Folder.page:1:', problem)
+
+ def test_a_protocol_relative_url_in_page_css_is_no_comment_but_one_in_its_php_is(self):
+ page = '\n"; ?>\n'
+ (problem,) = self.check({'Folder.page': page})
+ self.assertIn('Folder.page:1:', problem)
+
+ def test_no_files_to_check_fails_closed(self):
+ self.assertEqual(self.check({'README.md': 'x'}), [f'{ROOT}: no CSS, JS, PHP or .page files to check'])
+
+ def test_a_reason_comment_must_give_a_reason(self):
+ self.assertEqual(len(self.check({'styles/a.css': '/* !important: */\n.a { top: 0 !important }\n'})), 1)
+
+ def test_a_comment_or_a_content_string_that_mentions_it_is_not_a_use(self):
+ sheet = '/* never use !important here */\n.a::after { content: "!important"; }\n'
+ self.assertEqual(self.check({'styles/a.css': sheet}), [])
+
+ def test_a_script_needs_the_reason_on_its_line_or_the_line_above(self):
+ good = "// beats swal's !important rules\n// !important: no stylesheet may show a row while it is measured\nrow.style.cssText += ';visibility:hidden !important;';\n"
+ bad = "// hide the row\nrow.style.cssText += ';visibility:hidden !important;';\n"
+ self.assertEqual(self.check({'scripts/a.js': good}), [])
+ (problem,) = self.check({'scripts/b.js': bad})
+ self.assertIn('scripts/b.js:2:', problem)
+
+ def test_page_and_php_files_are_checked_too(self):
+ found = self.check({'Folder.page': 'Menu="x"\n---\n\n', 'server/a.php': " JSON.parse(execFileSync('php', ['-r', `${fn} $l = json_decode(stream_get_contents(STDIN), true); usort($l, 'fv3_name_cmp'); echo json_encode($l);`],
+// The shipped lib.order.php, required whole: it defines functions only
+const phpSort = (names) => JSON.parse(execFileSync('php', ['-r', `require $argv[1]; $l = json_decode(stream_get_contents(STDIN), true); usort($l, 'fv3_name_cmp'); echo json_encode($l);`,
+ path.join(plugin, 'server/lib.order.php')],
{ input: JSON.stringify(names), encoding: 'utf8' }));
const browserSort = (names) => names.slice().sort((a, b) => a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' }));
diff --git a/.github/scripts/package-lock.json b/.github/scripts/package-lock.json
index dc7d31db..5338d543 100644
--- a/.github/scripts/package-lock.json
+++ b/.github/scripts/package-lock.json
@@ -7,7 +7,7 @@
"name": "folder-view3-ci-tests",
"devDependencies": {
"jquery": "3.7.1",
- "jsdom": "31.0.0"
+ "jsdom": "31.0.1"
}
},
"node_modules/@exodus/bytes": {
@@ -154,9 +154,9 @@
"license": "MIT"
},
"node_modules/jsdom": {
- "version": "31.0.0",
- "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-31.0.0.tgz",
- "integrity": "sha512-xAkhD9z1eyFC5+QUi9K24CaZJgdCQ2GOGLW1GdVDoQvkp/AxEH9TQ0pAplPOlIiV92hfcgnFOADZypbjgbBT6Q==",
+ "version": "31.0.1",
+ "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-31.0.1.tgz",
+ "integrity": "sha512-CbhJL8ZQg3eKswxSZth4QO9tW0jPIhmR0vtSXQSbKSfWbwIT6hoRc17wdHIVTQ43KI0mdV5iTJr3281IDgVZ5g==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -202,9 +202,9 @@
}
},
"node_modules/parse5": {
- "version": "8.1.0",
- "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.0.tgz",
- "integrity": "sha512-sq3qBFpee5jeocbFbO48VHlGr8sT7mbXS0vxlKN6sottBtJzrOG3998sr0llSZcQAGgfpdmEYAIZE0P9z0dE8w==",
+ "version": "8.1.1",
+ "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.1.tgz",
+ "integrity": "sha512-EcR/6WDcU7b2N3vQSxKALCk9lXGtUMQxXio008OEMBE0kavu/7JLfBEeFPzi43nMqVDSbEn3QCK+BMCc9zO//w==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -215,13 +215,13 @@
}
},
"node_modules/parse5-parser-stream": {
- "version": "8.1.0",
- "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-8.1.0.tgz",
- "integrity": "sha512-58MPfNTA+DsIzro41rU94xghnu/h2N4yEPdPdGPlZVHM/QvA5jlVGYVo7IzlHbFLHYx3cZUnr9s9HBrA0tEYyw==",
+ "version": "8.1.1",
+ "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-8.1.1.tgz",
+ "integrity": "sha512-hMcVbbUJcQmP8rURWUdYrT1flRiBiBVjq/RYGguJpDUgIXSqdYKlE0CxthmdMWoSlBAuL5bUBa73g0pttSy7Hw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "parse5": "^8.0.0"
+ "parse5": "^8.1.1"
},
"funding": {
"url": "https://github.com/inikulin/parse5?sponsor=1"
@@ -251,29 +251,29 @@
}
},
"node_modules/tldts": {
- "version": "7.4.19",
- "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.4.19.tgz",
- "integrity": "sha512-48dH6aSpQnpbzDUc4vIQZ1VjB8tkK+e8c1yx05/SZK+rkssgjEOlxDd/yU8/a4vGYQ9vRgJr9dwMq9TJ0b3X2Q==",
+ "version": "7.5.4",
+ "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.5.4.tgz",
+ "integrity": "sha512-Rn2ABgjHZrA+jzqom5zhxA0hLohzYrIgfCPyhpTUxqsUrcsBYuab49LseR9waB9Jr8/MxdodvMHA91oRiGLO3Q==",
"dev": true,
"license": "MIT",
"dependencies": {
- "tldts-core": "^7.4.19"
+ "tldts-core": "^7.5.4"
},
"bin": {
"tldts": "bin/cli.js"
}
},
"node_modules/tldts-core": {
- "version": "7.4.20",
- "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.4.20.tgz",
- "integrity": "sha512-C630TWXZCZmLq0F2bW4QqwnaaxCQ/svpAqvJwnC4JvgEM5ohhBnGsEzTLSOXcN+xjz+kEaHS5uoWIw2klnqd0A==",
+ "version": "7.5.4",
+ "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.5.4.tgz",
+ "integrity": "sha512-9+4zWtKEDZ3V3FoZ1B97rv+5z5oqp7yeXGVze3CxgQ+CJro9do9DCPD00wxstYZDXDMXsurkBerFfiB6GYtPbA==",
"dev": true,
"license": "MIT"
},
"node_modules/tough-cookie": {
- "version": "6.0.2",
- "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz",
- "integrity": "sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==",
+ "version": "6.1.0",
+ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.1.0.tgz",
+ "integrity": "sha512-FTxc8u8Kl2tz0Lat1u8ksvcy8bwHRyEMawwTWybo51JqaC6O7SvfuhAKg+Ld6VqyIe2QRJBzY9HA7y2WyFRT2w==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
@@ -297,9 +297,9 @@
}
},
"node_modules/undici": {
- "version": "8.12.3",
- "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz",
- "integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==",
+ "version": "8.12.4",
+ "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.4.tgz",
+ "integrity": "sha512-8Mx+uNKKER2bA4AdtedkqRbwUCIJFr2nJckXRe5yrDqzePqwLP7VNcctN8/XdmDSbF7mS+jJKIszlL+vbam1VA==",
"dev": true,
"license": "MIT",
"engines": {
diff --git a/.github/scripts/package.json b/.github/scripts/package.json
index cab4cf12..3548b360 100644
--- a/.github/scripts/package.json
+++ b/.github/scripts/package.json
@@ -4,6 +4,6 @@
"description": "Test-only dependencies for the scripts in this folder; nothing here ships in the plugin",
"devDependencies": {
"jquery": "3.7.1",
- "jsdom": "31.0.0"
+ "jsdom": "31.0.1"
}
}
diff --git a/.github/scripts/page_order_test.php b/.github/scripts/page_order_test.php
index 58b8ce4b..edab0144 100644
--- a/.github/scripts/page_order_test.php
+++ b/.github/scripts/page_order_test.php
@@ -75,6 +75,7 @@ class DockerUpdate {}
$GLOBALS['fv3tDown'] = $names === null;
$setPrefs($cfg);
@unlink("$configDir/docker.json");
+ @unlink("$configDir/order-docker.json");
@unlink($fv3tAutostart);
if ($folders !== null) file_put_contents("$configDir/docker.json", json_encode((object)$folders));
if ($autostart !== null) file_put_contents($fv3tAutostart, is_array($autostart) ? implode("\n", $autostart) . "\n" : $autostart);
@@ -90,6 +91,12 @@ class DockerUpdate {}
$GLOBALS['fv3tDown'] = false;
}
};
+// $sync's run, answering with userprefs.cfg as the run left it (null = no file) in place of the autostart file
+$syncPrefs = function (?array $folders, array $names, ?string $cfg, ?callable $break = null) use ($sync, $fv3DockerManDir): array {
+ [$answer] = $sync($folders, $names, $cfg, null, $break);
+ $file = "$fv3DockerManDir/userprefs.cfg";
+ return [$answer, file_exists($file) ? file_get_contents($file) : null];
+};
// updateAutostartConfig() as the Autostart tab calls it, with the folder config as given
$autostartSave = function (string $mode, string $foldersJson, array $waits = [], bool $readOnly = false) use ($setPrefs, $configDir, $fv3tAutostart): array {
$GLOBALS['fv3tNames'] = ['a', 'b'];
@@ -204,11 +211,18 @@ class DockerUpdate {}
['folder-a', 'folder-b', 'folder-m', 'plex', 'folder-z']],
['no userprefs.cfg: a look-alike of a folder member keeps its own A-Z place',
$order(['f' => $folder('F', ['10'])], ['10', '1e1', '0first'], []), ['0first', '1e1', '10', 'folder-f']],
- ['read_membership.php: an explicit entry beats a label (s1), a label places a loose container (mid), the first folder whose regex matches wins (r1, y1)',
- $membership(null), [1, '200', ['alpha' => 'Dup', 'mid' => 'Zulu', 'n1' => 'Numbers', 'o1' => 'Old', 'r1' => 'Rex', 'r2' => 'Rex', 's1' => 'Seven', 'y1' => 'Yankee', 'y2' => 'Yankee', 'z1' => 'Zulu', 'z2' => 'Zulu']]],
- ['and its answer does not depend on userprefs.cfg: the saved order, a reversed one, a file cut off mid-save',
+ ['two folders\' regexes match a container: the folder userprefs.cfg names first takes it, as the page draws it',
+ $order(['a' => $folder('A', [], '^web'), 'b' => $folder('B', [], '^web')], ['web1', 'loose'], ['folder-b', 'loose', 'folder-a']),
+ ['web1', 'folder-b', 'loose', 'folder-a']],
+ ['folders userprefs.cfg does not name take theirs in JS key order, an index-like id first',
+ $order(['x' => $folder('X', [], '^web'), '7' => $folder('Seven', [], '^web')], ['web1', 'loose'], ['loose']), ['folder-x', 'web1', 'folder-7', 'loose']],
+ ['no userprefs.cfg: the folder first A-Z takes a container two regexes match',
+ $order(['z' => $folder('Zulu', [], '^web'), 'a' => $folder('Alpha', [], '^web')], ['web1'], []), ['web1', 'folder-a', 'folder-z']],
+ ['read_membership.php: an explicit entry beats a label (s1), a label places a loose container (mid); with nothing saved the folder first A-Z whose regex matches wins (Dup: r1, y1)',
+ $membership(null), [1, '200', ['alpha' => 'Dup', 'mid' => 'Zulu', 'n1' => 'Numbers', 'o1' => 'Old', 'r1' => 'Dup', 'r2' => 'Dup', 's1' => 'Seven', 'y1' => 'Dup', 'y2' => 'Dup', 'z1' => 'Zulu', 'z2' => 'Zulu']]],
+ ['with a saved order, the folders it names win first, then the rest (Rex, Yankee before Dup); a file cut off mid-save reads as nothing saved, as on the page',
[$membership($userprefs($fixture['prefs'])), $membership($userprefs(array_reverse($fixture['containers']))), $membership($cutOff)],
- array_fill(0, 3, $membership(null))],
+ [...array_fill(0, 2, [1, '200', ['alpha' => 'Dup', 'mid' => 'Zulu', 'n1' => 'Numbers', 'o1' => 'Old', 'r1' => 'Rex', 'r2' => 'Rex', 's1' => 'Seven', 'y1' => 'Yankee', 'y2' => 'Yankee', 'z1' => 'Zulu', 'z2' => 'Zulu']]), $membership(null)]],
['autostart lines follow the order and keep their wait value',
fv3_reorder_autostart(['a 5', 'b', 'c 10'], ['c', 'folder-f', 'a', 'a']), ['c 10', 'a 5', 'b']],
['a line the order does not name stays after the others, in file order',
@@ -248,23 +262,68 @@ class DockerUpdate {}
$sync([], ['b', 'a', 'c'], $cutOff, ['c', 'ghost', 'b 5', 'a']), ["Unraid's saved Docker order (userprefs.cfg) could not be read", ['c', 'ghost', 'b 5', 'a']]],
['an empty userprefs.cfg writes A-Z, as no userprefs.cfg does',
$sync([], ['b', 'a', 'c'], '', ['c', 'b 5', 'a']), [null, ['a', 'b 5', 'c']]],
+ ['userprefs.cfg: a folder member it lacks is saved right after its folder, in the folder\'s order',
+ $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], $userprefs(['a', 'folder-f', 'x', 'b'])), [null, $userprefs(['a', 'folder-f', 'x', 'y', 'b'])]],
+ ['userprefs.cfg: a member saved away from its folder moves to it',
+ $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], $userprefs(['y', 'a', 'folder-f', 'x', 'b'])), [null, $userprefs(['a', 'folder-f', 'x', 'y', 'b'])]],
+ ['userprefs.cfg: a member moved to another folder follows it',
+ $syncPrefs(['f' => $folder('F', ['x']), 'g' => $folder('G', ['w', 'y'])], ['w', 'x', 'y'], $userprefs(['folder-f', 'x', 'y', 'folder-g', 'w'])), [null, $userprefs(['folder-f', 'x', 'folder-g', 'w', 'y'])]],
+ ['userprefs.cfg: members saved before their folder, as FV3\'s own writers save them, stay before it',
+ $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'x', 'y'], $userprefs(['x', 'folder-f', 'a'])), [null, $userprefs(['x', 'y', 'folder-f', 'a'])]],
+ ['userprefs.cfg: a regex folder\'s members keep the saved order, on their side of its entry',
+ $syncPrefs(['r' => $folder('Rx', [], '^web')], ['web1', 'web2', 'db'], $userprefs(['web2', 'folder-r', 'db', 'web1'])), [null, $userprefs(['web2', 'web1', 'folder-r', 'db'])]],
+ ['userprefs.cfg: a folder with none of its members saved yet, as after an install, gets them after its entry',
+ $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $userprefs(['folder-f', 'a'])), [null, $userprefs(['folder-f', 'x', 'a'])]],
+ ['userprefs.cfg: a folder it has no entry for leaves its members where they are',
+ $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'x', 'y'], $userprefs(['x', 'a', 'y'])), [null, $userprefs(['x', 'a', 'y'])]],
+ ['userprefs.cfg: an entry Docker does not have keeps its place',
+ $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $userprefs(['ghost', 'folder-f', 'a', 'x'])), [null, $userprefs(['ghost', 'folder-f', 'x', 'a'])]],
+ ['userprefs.cfg: none is not created, so Unraid keeps its A-Z order',
+ $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], null), [null, null]],
+ ['userprefs.cfg: an empty one stays empty',
+ $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], ''), [null, '']],
+ ['userprefs.cfg: one already in place is not written again, its numbering kept',
+ $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['x', 'y'], "0=\"folder-f\"\n2=\"x\"\n5=\"y\"\n"), [null, "0=\"folder-f\"\n2=\"x\"\n5=\"y\"\n"]],
+ ['userprefs.cfg: the fixture\'s saved order is already in place',
+ $syncPrefs($fixture['folders'], $fixture['containers'], $userprefs($fixture['prefs'])), [null, $userprefs($fixture['prefs'])]],
+ ['userprefs.cfg: custom and off modes regroup it too, and leave the autostart file to their own rule',
+ array_map(fn($mode) => [...$sync(['f' => $folder('F', ['x'])], ['a', 'x'], $userprefs(['x', 'a', 'folder-f']), ['x', 'a'],
+ fn() => file_put_contents("$configDir/autostart.json", json_encode(['mode' => $mode, 'sequence' => ['a', 'x']]))), file_get_contents("$fv3DockerManDir/userprefs.cfg")], ['custom', 'off']),
+ [[null, ['a', 'x'], $userprefs(['a', 'folder-f', 'x'])], [null, ['x', 'a'], $userprefs(['a', 'folder-f', 'x'])]]],
+ ['userprefs.cfg: a name that cannot be written back (a quote another tool saved) leaves it as it is, and is reported',
+ $syncPrefs(['f' => $folder('F', ['x'])], ['x'], "0=\"x\"\n1=\"a\\\"b\"\n2=\"folder-f\"\n"),
+ ["Unraid's saved Docker order (userprefs.cfg) holds a name that cannot be written back", "0=\"x\"\n1=\"a\\\"b\"\n2=\"folder-f\"\n"]],
+ ['userprefs.cfg: an order saved while the sync worked it out is kept as it is',
+ (function () use ($setPrefs, $userprefs, $folder, $fv3DockerManDir) {
+ $read = ['x', 'b', 'folder-f'];
+ $setPrefs($userprefs(['folder-f', 'x', 'b']));
+ return [fv3_sync_user_prefs($read, fv3_compute_folder_membership(['f' => $folder('F', ['x'])], ['b', 'x'], [], $read)), file_get_contents("$fv3DockerManDir/userprefs.cfg")];
+ })(), [null, $userprefs(['folder-f', 'x', 'b'])]],
+ ['userprefs.cfg: FV3\'s order snapshot, which the heal restores from after a reinstall, is saved with it',
+ [$syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $userprefs(['x', 'a', 'folder-f']))[1], fv3_export_order_snapshot('docker')['entries'] ?? null],
+ [$userprefs(['a', 'folder-f', 'x']), ['a', 'folder-f', 'x']]],
+ ['userprefs.cfg: a cut-off one is left as it is, and reported',
+ $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $cutOff), ["Unraid's saved Docker order (userprefs.cfg) could not be read", $cutOff]],
+ ['userprefs.cfg: the start order worked out from it is the same before and after the update (the page: docker_saved_places_test.js)',
+ $order(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], fv3_parse_user_prefs($syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], $userprefs(['y', 'a', 'folder-f', 'b']))[1])),
+ $order(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], ['y', 'a', 'folder-f', 'b'])],
['no containers, or Docker not running (Unraid\'s client answers an empty list): nothing is written, nothing is reported',
$sync([], [], null, ['b', 'a']), [null, ['b', 'a']]],
['a container list with an unnamed entry: nothing is written, and it is reported',
$sync([], ['a', ''], null, ['b', 'a']), ["Docker's container list could not be read", ['b', 'a']]],
['a failed label read: nothing is written, and it is reported',
$sync([], ['a', 'b'], null, ['b', 'a'], function () { $GLOBALS['fv3tLabelsDown'] = true; }), ['the container labels could not be read', ['b', 'a']]],
- ['custom mode does not read the folder config, so a damaged one does not stop it',
+ ['custom mode still writes its sequence when a damaged folder config stops the userprefs.cfg update, and says so',
$sync([], ['a', 'b'], null, ['b', 'a'], function () use ($configDir) {
file_put_contents("$configDir/docker.json", '{');
file_put_contents("$configDir/autostart.json", '{"mode":"custom","sequence":["a","b"]}');
- }), [null, ['a', 'b']]],
+ }), ['the folder config could not be read', ['a', 'b']]],
['a missing plugin config folder (deleted by hand under an open tab) is "no folders", not a failure: the sync runs and reports nothing',
[$syncWithoutConfigDir(['b', 'a']), $syncWithoutConfigDir([]), is_dir($configDir)], [[null, ['a', 'b']], [null, ['b', 'a']], true]],
['a damaged folder config is reported',
$sync([], ['a', 'b'], null, ['b', 'a'], fn() => file_put_contents("$configDir/docker.json", '{')), ['the folder config could not be read', ['b', 'a']]],
- ['autostart mode off reads nothing and reports nothing',
- $sync([], ['a', 'b'], $cutOff, ['b', 'a'], fn() => file_put_contents("$configDir/autostart.json", '{"mode":"off"}')), [null, ['b', 'a']]],
+ ['autostart mode off leaves the autostart file as it is, and reports a userprefs.cfg it cannot read',
+ $sync([], ['a', 'b'], $cutOff, ['b', 'a'], fn() => file_put_contents("$configDir/autostart.json", '{"mode":"off"}')), ["Unraid's saved Docker order (userprefs.cfg) could not be read", ['b', 'a']]],
['custom mode writes its saved sequence, the rest after it in file order',
$sync([], ['a', 'b', 'c'], null, ['b 5', 'a', 'ghost', 'c'], fn() => file_put_contents("$configDir/autostart.json", '{"mode":"custom","sequence":["c","a"]}')), [null, ['c', 'a', 'b 5']]],
['custom mode: a file already in its sequence is not written again',
@@ -319,6 +378,16 @@ class DockerUpdate {}
[['success' => true, 'mode' => 'off', 'sequence' => [], 'warning' => 'the wait edits could not be written to the autostart file'],
['success' => true, 'mode' => 'folder', 'sequence' => [], 'warning' => 'the wait edits could not be written to the autostart file; the autostart file could not be written'],
['success' => true, 'mode' => 'off', 'sequence' => []], ['b', 'a 30']]];
+ $cases[] = ['userprefs.cfg: a failed write is reported, and the autostart file is still put in order',
+ (function () use ($sync, $folder, $userprefs, $fv3DockerManDir) {
+ try { return $sync(['f' => $folder('F', ['x'])], ['a', 'b', 'x'], $userprefs(['b', 'folder-f', 'a', 'x']), ['a', 'x', 'b'], fn() => chmod($fv3DockerManDir, 0555)); }
+ finally { chmod($fv3DockerManDir, 0755); }
+ })(), ["Unraid's saved Docker order (userprefs.cfg) could not be updated", ['b', 'x', 'a']]];
+ $cases[] = ['userprefs.cfg and the autostart file both not written: both are reported',
+ (function () use ($sync, $folder, $userprefs, $fv3DockerManDir, $fv3tAutostart) {
+ try { return $sync(['f' => $folder('F', ['x'])], ['a', 'b', 'x'], $userprefs(['b', 'folder-f', 'a', 'x']), ['a', 'x', 'b'], function () use ($fv3DockerManDir, $fv3tAutostart) { chmod($fv3DockerManDir, 0555); chmod($fv3tAutostart, 0444); }); }
+ finally { chmod($fv3DockerManDir, 0755); }
+ })(), ["Unraid's saved Docker order (userprefs.cfg) could not be updated; the autostart file could not be written", ['a', 'x', 'b']]];
$cases[] = ['custom mode reports it too',
$sync([], ['a', 'b'], null, ['b', 'a'], function () use ($configDir, $fv3tAutostart) { file_put_contents("$configDir/autostart.json", '{"mode":"custom","sequence":["a","b"]}'); chmod($fv3tAutostart, 0444); }), ['the autostart file could not be written', ['b', 'a']]];
}
@@ -398,10 +467,10 @@ class DockerUpdate {}
};
$cases[] = ['folder import, no saved order: the new folders first in the file\'s order, each after its members, then the rest A-Z',
$importOrder(null, ['n2', 'n1'], ['a', 'b', 'c']), ['200', true, null, null, $userprefs(['folder-n2', 'b', 'folder-n1', 'c', 'a', 'folder-old'])]];
-$cases[] = ['folder import, a saved order: the new folders go on top in the file\'s order, the saved entries after them as they were',
- $importOrder($keep, ['n2', 'n1'], ['a', 'b', 'c']), ['200', true, null, null, $userprefs(['folder-n2', 'folder-n1', 'alpha', 'zed'])]];
-$cases[] = ['folder import, a saved order that already places one of them: that one keeps its place, an id with no folder is not written',
- $importOrder($userprefs(['alpha', 'folder-n1', 'zed']), ['n2', 'n1', 'ghost'], ['a', 'b', 'c']), ['200', true, null, null, $userprefs(['folder-n2', 'alpha', 'folder-n1', 'zed'])]];
+$cases[] = ['folder import, a saved order: the new folders go on top in the file\'s order with their members, the saved entries after them as they were',
+ $importOrder($keep, ['n2', 'n1'], ['a', 'b', 'c']), ['200', true, null, null, $userprefs(['folder-n2', 'folder-n1', 'b', 'alpha', 'zed'])]];
+$cases[] = ['folder import, a saved order that already places one of them: that one keeps its place with its member, an id with no folder is not written',
+ $importOrder($userprefs(['alpha', 'folder-n1', 'zed']), ['n2', 'n1', 'ghost'], ['a', 'b', 'c']), ['200', true, null, null, $userprefs(['folder-n2', 'alpha', 'folder-n1', 'b', 'zed'])]];
$cases[] = ['folder import, a saved order holding a list line: said, and left as it was',
$importOrder("0=\"a\"\n1[]=\"b\"\n", ['n1'], ['a', 'b']), ['200', true, "Unraid's saved Docker order (userprefs.cfg) could not be read", "Unraid's saved Docker order (userprefs.cfg) could not be read", "0=\"a\"\n1[]=\"b\"\n"]];
$cases[] = ['folder import, a saved order and a folder config that will not parse: said, and the order left as it was',
diff --git a/.github/scripts/php_tests.sh b/.github/scripts/php_tests.sh
new file mode 100755
index 00000000..53457d56
--- /dev/null
+++ b/.github/scripts/php_tests.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+# php -l over every plugin .php and .page file, then every .github/scripts/*_test.php, with every error level on.
+# Every PHP process logs to one file, the endpoints the tests start included; a deprecation there fails like an error.
+set -u
+cd "$(dirname "$0")/../.." || exit 2
+status=0
+ini=$(mktemp -d)
+trap 'rm -rf "$ini"' EXIT
+log=$ini/errors.log
+: > "$log"
+printf 'error_reporting=-1\nlog_errors=1\nerror_log=%s\n' "$log" > "$ini/zz-fv3-tests.ini"
+# An empty entry keeps PHP's own scan folder; this file loads after it, in every child process too
+export PHP_INI_SCAN_DIR="${PHP_INI_SCAN_DIR:-}:$ini"
+php -v | head -1
+php -r 'exit((error_reporting() & E_ALL) === E_ALL && ini_get("log_errors") ? 0 : 1);' || { echo 'FAILED: the error-log settings did not load'; exit 1; }
+
+deprecated() { # deprecated : fails the run when logged a deprecation
+ local seen; seen=$(grep -c 'Deprecated:' "$log")
+ if [ "$seen" -gt "${logged:-0}" ]; then
+ echo "FAILED: $1 ran into a deprecation:"
+ grep 'Deprecated:' "$log" | tail -n "$((seen - ${logged:-0}))"
+ status=1
+ fi
+ logged=$seen
+}
+
+while IFS= read -r -d '' f; do
+ php -l "$f" >/dev/null 2>&1 || { php -l "$f"; status=1; }
+done < <(find src \( -name '*.php' -o -name '*.page' \) -print0)
+deprecated 'php -l'
+
+for t in .github/scripts/*_test.php; do
+ echo "== $t"
+ php -d display_errors=stderr "$t" || status=1
+ deprecated "$t"
+done
+exit $status
diff --git a/.github/scripts/preview_pages_harness.js b/.github/scripts/preview_pages_harness.js
index 0ad69e6f..0f094b0e 100644
--- a/.github/scripts/preview_pages_harness.js
+++ b/.github/scripts/preview_pages_harness.js
@@ -252,7 +252,7 @@ const dockerRow = (name, sid) => `
`;
// The Docker page drawn by the real createFolders() from docker.json's folders, Docker's container names and userprefs.cfg's values
-const drawDocker = async ({ folders, containers, prefs, listed }) => {
+const drawDocker = async ({ folders, containers, prefs, listed, api = false }) => {
const sid = (i) => String(i).padStart(12, 'a');
const defs = Object.fromEntries(Object.entries(folders).map(([id, f]) => [id, { ...f, icon: '', settings: { ...FOLDER_SETTINGS }, hidden_preview: [], actions: [] }]));
const saved = prefs.filter((n) => containers.includes(n));
@@ -261,7 +261,7 @@ const drawDocker = async ({ folders, containers, prefs, listed }) => {
// false = 0); how it orders several missing ones among themselves is its own tie-break, so they stay as given
const shown = missing.concat(saved);
const info = {};
- const p = await makePage({ page: 'docker', api: false, answers: {
+ const p = await makePage({ page: 'docker', api, answers: {
'read.php': () => JSON.stringify(defs),
'read_order.php': () => JSON.stringify(prefs),
'read_info.php': () => JSON.stringify(info),
@@ -305,6 +305,27 @@ const drawDocker = async ({ folders, containers, prefs, listed }) => {
return { p, posts, failing, dropped, render, draw, rows, members, drawn };
};
+// Unraid's row for one VM (VMMachines.php), stopped, with its hidden detail row
+const vmRow = (name, i) => `
") . ' container rows, not 4');
+foreach ($containers as $ct) check(str_contains($body, $ct), "Docker list has no row for $ct");
+[$status, $body] = req('GET', '/plugins/dynamix.vm.manager/include/VMMachines.php');
+check($status === 200 && preg_match_all("/
/", $body) === 3, "VM list: status $status, not 3 VM rows");
+foreach ($vms as $vm) check(str_contains($body, $vm), "VM list has no row for $vm");
+[$status, $body] = req('POST', '/webGui/include/DashboardApps.php', ['docker' => 1, 'vms' => 1, 'vmusage' => 'N']);
+foreach (array_merge($containers, $vms) as $name) check($status === 200 && str_contains($body, $name), "Dashboard tiles: status $status, no tile for $name");
+
+// FV3's reads; the Docker and VM ones answer from what Unraid's own code got from the fakes
+$info = get_json('read_info.php?type=docker', $status);
+check($status === 200 && is_array($info) && $sorted(array_keys($info)) === $containers, "read_info docker: status $status, containers " . json_encode(is_array($info) ? array_keys($info) : $info));
+if (is_array($info) && $sorted(array_keys($info)) === $containers) {
+ $seen = array_map(fn($c) => [$c['info']['State']['Autostart'], $c['info']['State']['Running'], $c['info']['State']['WebUi'], $c['info']['template']['path'] ?? null, $c['shortId']], $info);
+ ksort($seen);
+ // [IP] is ipaddr() on 7.0 (network.ini's address); from 7.1 DockerUtil::host() needs a LAN port, which a container with no network lacks
+ $webui = version_compare($version, '7.1', '<') ? 'http://192.0.2.10:18080/' : 'http://:18080/';
+ check($seen === [
+ 'app-a' => [true, true, $webui, '/boot/config/plugins/dockerMan/templates-user/my-app-a.xml', $shortId('app-a')],
+ 'app-b' => [false, true, '', null, $shortId('app-b')],
+ 'app-d' => [true, true, '', null, $shortId('app-d')],
+ 'tool-c' => [false, false, '', null, $shortId('tool-c')],
+ ], 'read_info docker: autostart, running, WebUI, template or short id wrong: ' . json_encode($seen));
+}
+$info = get_json('read_info.php?type=vm', $status);
+check($status === 200 && is_array($info) && $sorted(array_keys($info)) === $vms, "read_info vm: status $status, VMs " . json_encode(is_array($info) ? array_keys($info) : $info));
+if (is_array($info) && $sorted(array_keys($info)) === $vms) {
+ $seen = array_map(fn($v) => [$v['state'], $v['autostart'], $v['icon'], $v['vnc_port']], $info);
+ check($seen === [
+ 'Debian 12' => ['running', 1, '/plugins/dynamix.vm.manager/templates/images/debian.png', '5700'],
+ 'Windows 11' => ['shutoff', false, '/plugins/dynamix.vm.manager/templates/images/windows11.png', ''],
+ 'Home Assistant' => ['paused', 1, '/plugins/dynamix.vm.manager/templates/images/linux.png', '5701'],
+ ], 'read_info vm: state, autostart, icon or VNC port wrong: ' . json_encode($seen));
+ check($info['Debian 12']['description'] === 'Debian 12 lab server', 'read_info vm: description lost');
+}
+check(get_json('read_unraid_order.php?type=docker', $status) === ['app-a', 'app-b', 'tool-c', 'app-d'] && $status === 200, 'read_unraid_order docker: not the saved order');
+check(get_json('read_unraid_order.php?type=vm', $status) === ['Debian 12', 'Home Assistant', 'Windows 11'] && $status === 200, 'read_unraid_order vm: not the saved order');
+$membership = get_json('read_membership.php?type=docker', $status);
+check($status === 200 && ($membership['membership'] ?? null) === ['app-a' => 'Media', 'app-b' => 'Media', 'tool-c' => 'Tools'],
+ "read_membership: status $status, " . json_encode($membership));
+[$status, $body] = req('GET', '/plugins/folder.view3/server/docker_load.php');
+$load = explode("\n", trim($body));
+sort($load);
+$want = array_map(fn($n) => $shortId($n) . ';0.50%;12.5MiB / 7.7GiB', ['app-a', 'app-b', 'app-d']);
+sort($want);
+check($status === 200 && $load === $want, "docker_load: status $status, " . json_encode($load));
+$image = array_key_first($fixture['image_inspect']);
+$env = get_json('read_image_env.php?image=' . urlencode($image), $status);
+check($status === 200 && $env === ['env' => ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin']], "read_image_env: status $status, " . json_encode($env));
+$folders = get_json('read.php?type=docker', $status);
+check($status === 200 && $folders === [$media => $read($mediaFolder), $tools => $read($toolsFolder)], 'read docker: ' . json_encode($folders));
+$folders = get_json('read.php?type=vm', $status);
+check($status === 200 && $folders === [$lab => $read($labFolder)], 'read vm: ' . json_encode($folders));
+$autostart = get_json('read_autostart.php', $status);
+check($status === 200 && ($autostart['autostart'] ?? null) === [['name' => 'app-a', 'wait' => 0], ['name' => 'app-d', 'wait' => 10]], 'read_autostart: ' . json_encode($autostart));
+// Unraid's saved orders, and no FV3 settings, themes, styles or organizer folders yet; re-encoded, so {} and [] stay apart
+$exact = [
+ 'read_order.php?type=docker' => json_encode(["folder-$media", 'app-a', 'app-b', "folder-$tools", 'tool-c', 'app-d']),
+ 'read_order.php?type=vm' => json_encode(["folder-$lab", 'Debian 12', 'Home Assistant', 'Windows 11']),
+ 'read_settings.php' => '{}', 'list_themes.php' => '[]', 'read_css_config.php' => '{}', 'read_organizer_registry.php' => '{"folders":[]}',
+];
+foreach ($exact as $path => $want) {
+ [$status, $body] = req('GET', "/plugins/folder.view3/server/$path");
+ check($status === 200 && json_encode(json_decode($body)) === $want, "$path: status $status, " . substr($body, 0, 200));
+}
+// All 49 of the CSS tool's defaults, two of them by value
+$defaults = get_json('read_css_defaults.php', $status);
+check($status === 200 && is_array($defaults) && count($defaults) === 49 && ($defaults['folder-view3-graph-cpu'] ?? null) === '#2b8da3'
+ && ($defaults['fv3-folder-name-min-width'] ?? null) === '220px', "read_css_defaults: status $status, " . substr(json_encode($defaults), 0, 200));
+// The backup: the seeded folders and nothing else of FV3's yet, stamped with this Unraid, this FV3 and the time
+$export = get_json('export_all.php', $status);
+$stamp = strtotime((string)($export['exported'] ?? ''));
+unset($export['exported']);
+check($status === 200 && $export === ['fv3_export_version' => 1, 'plugin_version' => '2099.01.01', 'unraid_version' => $version,
+ 'docker' => [$media => $mediaFolder, $tools => $toolsFolder], 'vm' => [$lab => $labFolder], 'settings' => [], 'autostart' => [],
+ 'css_config' => [], 'custom_styles' => [], 'order_docker' => [], 'order_vm' => []], "export_all: status $status, " . json_encode($export));
+check($stamp !== false && abs($stamp - time()) < 300, 'export_all: not stamped with the time');
+// FV3's debug panel shows the error log's last 200 lines; what those lines may hold is checked with the logs below
+$raw = trim((string)@file_get_contents("$flash/error.log"));
+$log = get_json('read_error_log.php', $status);
+check($status === 200 && $log === ['log' => implode("\n", array_slice($raw === '' ? [] : explode("\n", $raw), -200))], "read_error_log: status $status, not the log's tail");
+[$status, $body] = req('GET', '/plugins/folder.view3/server/version.php');
+check($status === 200 && $body === '2099.01.01', "version: status $status, $body");
+// Logical CPUs, as this container's /proc/cpuinfo lists them
+$cpus = count(preg_grep('/^processor\s*:/', file('/proc/cpuinfo')));
+[$status, $body] = req('GET', '/plugins/folder.view3/server/cpu.php');
+check($status === 200 && trim($body) === (string)$cpus, "cpu: status $status, $body, not $cpus");
+$leaves("FV3's reads");
+
+// FV3's pages in every theme: rendered whole, Unraid's lists that FV3's scripts fold present, FV3's own part present, and every
+// file that part links served by this Unraid
+$pages = [
+ 'Docker' => ['folder.view3.Docker.page', ['/plugins/folder.view3/scripts/docker.js', '/plugins/folder.view3/styles/docker.css'], ['docker_list', 'loadlist()']],
+ 'VMs' => ['folder.view3.VMs.page', ['/plugins/folder.view3/scripts/vm.js', '/plugins/folder.view3/styles/vm.css'], ['kvm_table', 'kvm_list', 'loadlist()']],
+ 'Dashboard' => ['folder.view3.Dashboard.page', ['/plugins/folder.view3/scripts/dashboard.js', '/plugins/folder.view3/styles/dashboard.css'], ['docker_view', 'vm_view', 'loadlist()']],
+ 'Settings/FolderView3' => ['FolderView3.page', ['/plugins/folder.view3/scripts/folderview3.js', '/plugins/folder.view3/styles/folderview3.css'], []],
+ "Folder?type=docker&id=$media" => ['Folder.page', ['/plugins/folder.view3/scripts/folder.js', '/plugins/folder.view3/styles/folder.css'], []],
+];
+$served = [];
+@mkdir('/boot/config/plugins/dynamix', 0777, true);
+foreach (['black', 'white', 'azure', 'gray'] as $theme) {
+ file_put_contents('/boot/config/plugins/dynamix/dynamix.cfg', "[display]\ntheme=\"$theme\"\n");
+ foreach ($pages as $page => [$file, $needs, $unraid]) {
+ [$status, $html] = req('GET', "/$page");
+ $where = "$page ($theme)";
+ check($status === 200 && str_contains($html, '