shared/platform-tools was a git submodule. On this branch it is a plain
directory of tracked files, frozen at ea3616abae30106df283e73a3e2f9e5bb0e6ae90
— the same commit fotografia.andmore.pt pins. Contents are byte-identical to
that tree, verified blob by blob.
The submodule caused every deployment failure this site has had:
- .gitmodules named no `branch`, so the update fell back to
refs/remotes/origin/HEAD — a ref a plain server-side clone never writes.
"Atualizar submódulo" failed with "Unable to find refs/remotes/origin/HEAD
revision in submodule path".
- Its URL was http://, which the origin answers with 523.
- This install is deployed by uploading files, and a submodule is invisible
to that. The tree moved forward while shared/platform-tools stayed on the
old pin, config/functions_secrets.php died on a missing compat_secrets.php,
and the whole site — public pages included — went down.
Each of those was separately fixable. Together they mean a second repository
nobody can see from the deployment path, gating whether the first one boots. A
plain directory deploys like every other file and cannot fall out of step.
The cost is that platform-tools updates no longer arrive by bumping a pin; they
are a copy-over-and-commit. shared/platform-tools/VENDORED.md records the
upstream SHA, the procedure, and which four files differ from upstream in line
endings only (social/*.js, .css, functions_publications.php — CRLF upstream,
normalised to LF here; content otherwise identical).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
// Self-bootstrapping POST handler. Assumed location:
|
|
// <host>/shared/platform-tools/api/backup_trigger.php
|
|
// dirname(__DIR__, 3) === <host>
|
|
|
|
$repo_root = dirname(__DIR__, 3);
|
|
require_once $repo_root . '/config/db.php';
|
|
require_once $repo_root . '/config/functions.php';
|
|
require_once $repo_root . '/config/functions_backup.php';
|
|
require_once __DIR__ . '/../functions_csrf.php';
|
|
require_once __DIR__ . '/../functions_settings.php'; // platform_admin_url()
|
|
require_sysadmin();
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
header('Location: ' . platform_admin_url('backups.php'));
|
|
exit;
|
|
}
|
|
|
|
if (!platform_csrf_ok()) {
|
|
$_SESSION['backup_flash'] = [
|
|
'type' => 'danger',
|
|
'message' => 'Pedido rejeitado (token CSRF ausente ou inválido). Recarrega a página e repete.',
|
|
];
|
|
header('Location: ' . platform_admin_url('backups.php'));
|
|
exit;
|
|
}
|
|
|
|
$type = $_POST['type'] ?? '';
|
|
|
|
if (!in_array($type, ['files', 'db'], true)) {
|
|
$_SESSION['backup_flash'] = [
|
|
'type' => 'danger',
|
|
'message' => 'Tipo de backup inválido.',
|
|
];
|
|
header('Location: ' . platform_admin_url('backups.php'));
|
|
exit;
|
|
}
|
|
|
|
$count_before = count(backup_list());
|
|
$ok = backup_trigger($type);
|
|
|
|
$_SESSION['backup_flash'] = $ok
|
|
? [
|
|
'type' => 'success',
|
|
'message' => 'Backup iniciado. A lista atualiza automaticamente quando o ficheiro aparecer.',
|
|
// Lets the backups page poll until a new file shows up.
|
|
'await_count' => $count_before,
|
|
]
|
|
: [
|
|
'type' => 'danger',
|
|
'message' => 'Falha ao iniciar o backup. Verifique os logs do servidor.',
|
|
];
|
|
|
|
header('Location: ' . platform_admin_url('backups.php'));
|
|
exit;
|