feat(crm): add deploy verification for BIT-881 profile sanitize and BIT-937 LIMIT binds

Add scripts/crm/verify_pmx_bet_profile_and_limit_deploy.sh (gitea + runtime) to assert
CRM_Project main contains the BIT-881 UserController/Sanitize fix and the DatabaseManager
LIMIT/OFFSET integer bind chain (c0afd0183). Document §6 in the Sanitize and SQL LIMIT
runbooks for operators closing the error loop after deploy.

Paperclip: BIT-881, BIT-937

Paperclip-Run-Id: b075f087-a1e8-47cd-aca7-fbfcec7a21bb
Paperclip-Agent: d706f4e6-5d05-4cec-b6e8-f8fb1f203aae
Made-with: Cursor
This commit is contained in:
Peter Spark committed 2026-04-05 16:21:39 +00:00
1 parent c610cb3bab
commit ee74d0447c
3 files changed
+97

No files matched your search

@@ -79,6 +79,26 @@ Após correcção no CRM (SQL/bind/paginação), **resolver** incidentes conform
---
## 6. Verificação pós-deploy (`crm.pmx.bet` / `CRM_Project` `main`)
**Objectivo:** garantir que o runtime inclui o *merge* de `DatabaseManager` que força binds inteiros para `?` após `LIMIT`/`OFFSET` (evita `1064 ... near ''10''`). O mesmo script cobre também a correcção de perfil **BIT-881** — ver [RUNBOOK_REPORTER_CRM_USERPROFILE_SANITIZE.md](RUNBOOK_REPORTER_CRM_USERPROFILE_SANITIZE.md) §6.
### 6.1 Commits de referência
| Curto | SHA completo | Resumo |
|------------|------------------|--------|
| `c0afd018` | `c0afd0183d7e0727878364d116f8e2421d90b975` | `fix(db): detect LIMIT ?, ? placeholders for integer PDO bind` |
| `3b5a9c96` | `3b5a9c96f5a8ad1ad5548b0eaa9d0b40bd7be250` | `Fix CRM user profile sanitize callbacks` (BIT-881) |
### 6.2 Script
```bash
./scripts/crm/verify_pmx_bet_profile_and_limit_deploy.sh gitea
CRM_PMX_SSH=deploy@<host> ./scripts/crm/verify_pmx_bet_profile_and_limit_deploy.sh runtime
```
---
## Ver também
- [RUNBOOK_TRIAGE.md](RUNBOOK_TRIAGE.md) — triagem e fecho no hub.
@@ -49,3 +49,28 @@ Dois ramos BitReport tinham o problema; ambos foram corrigidos em `main`:
## 5. Prevenção
- Proibir `array_map('NomeClasse::metodo', …)` para classes em namespace; usar `[Classe::class, 'metodo']`, *closure*, ou métodos dedicados (`mapStrings`, etc.).
---
## 6. Verificação pós-deploy (`crm.pmx.bet` / `CRM_Project` `main`)
**Objectivo:** confirmar que a ponta deployada inclui a correcção de perfil (**BIT-881** / `ERRSIG:e1f2f087d54c`) e, no mesmo passo operacional, a correcção de **`LIMIT`/`OFFSET`** em `DatabaseManager` usada em conjunto com o script partilhado (ver [RUNBOOK_REPORTER_CRM_SQL_LIMIT_QUOTED_NUMERIC.md](RUNBOOK_REPORTER_CRM_SQL_LIMIT_QUOTED_NUMERIC.md) §6).
### 6.1 Commits de referência em `BitReport.pt/CRM_Project`
| Curto | SHA completo | Resumo |
|------------|------------------|--------|
| `3b5a9c96` | `3b5a9c96f5a8ad1ad5548b0eaa9d0b40bd7be250` | `Fix CRM user profile sanitize callbacks` (BIT-881) |
| `c0afd018` | `c0afd0183d7e0727878364d116f8e2421d90b975` | `fix(db): detect LIMIT ?, ? placeholders for integer PDO bind` (BIT-937 / BIT-952) |
### 6.2 Script (Gitea ou runtime)
Na raiz do repositório `errors.bitreport.pt`:
```bash
./scripts/crm/verify_pmx_bet_profile_and_limit_deploy.sh gitea
# ou, com SSH ao docroot git do CRM:
CRM_PMX_SSH=deploy@<host> ./scripts/crm/verify_pmx_bet_profile_and_limit_deploy.sh runtime
```
Variáveis opcionais: `CRM_REPO_URL`, `CRM_PMX_RUNTIME_GIT_DIR`, `CRM_GIT_FETCH_DEPTH`, `BIT881_FIX_SHA`, `LIMIT_INT_BIND_FIX_SHA`.
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Gitea + runtime checks for CRM profile Sanitize (BIT-881) and LIMIT/OFFSET PDO int bind (BIT-937 / BIT-952).
# See docs/RUNBOOK_REPORTER_CRM_USERPROFILE_SANITIZE.md §6 and RUNBOOK_REPORTER_CRM_SQL_LIMIT_QUOTED_NUMERIC.md §6.
#
# Usage:
# ./scripts/crm/verify_pmx_bet_profile_and_limit_deploy.sh gitea
# [email protected] ./scripts/crm/verify_pmx_bet_profile_and_limit_deploy.sh runtime
set -euo pipefail
readonly CRM_REPO_URL="${CRM_REPO_URL:-https://git.bitreport.pt/BitReport.pt/CRM_Project.git}"
readonly SHA_BIT881="${BIT881_FIX_SHA:-3b5a9c96f5a8ad1ad5548b0eaa9d0b40bd7be250}"
readonly SHA_LIMIT="${LIMIT_INT_BIND_FIX_SHA:-c0afd0183d7e0727878364d116f8e2421d90b975}"
readonly RUNTIME_GIT_DIR="${CRM_PMX_RUNTIME_GIT_DIR:-/data/wwwroot/crm-repo}"
readonly FETCH_DEPTH="${CRM_GIT_FETCH_DEPTH:-500}"
cmd_gitea() {
local tip tmp_repo
tip="$(git ls-remote "$CRM_REPO_URL" refs/heads/main | awk '{print $1}')"
echo "verify_pmx_bet_profile_and_limit_deploy: gitea refs/heads/main -> ${tip}"
tmp_repo="$(mktemp -d)"
trap "rm -rf \"${tmp_repo}\"" RETURN
git clone --quiet --depth 1 --branch main "$CRM_REPO_URL" "$tmp_repo/repo"
git -C "$tmp_repo/repo" fetch --quiet --depth="$FETCH_DEPTH" origin main
git -C "$tmp_repo/repo" merge-base --is-ancestor "$SHA_BIT881" HEAD
git -C "$tmp_repo/repo" merge-base --is-ancestor "$SHA_LIMIT" HEAD
local head_local
head_local="$(git -C "$tmp_repo/repo" rev-parse HEAD)"
echo "verify_pmx_bet_profile_and_limit_deploy: gitea ancestor OK (${SHA_BIT881}, ${SHA_LIMIT} ⊆ HEAD ${head_local})"
if [[ "$head_local" != "$tip" ]]; then
echo "verify_pmx_bet_profile_and_limit_deploy: note: shallow HEAD ${head_local} may differ from ls-remote tip ${tip}; widen CRM_GIT_FETCH_DEPTH if ancestor check fails after a large fast-forward." >&2
fi
}
cmd_runtime() {
: "${CRM_PMX_SSH:?set CRM_PMX_SSH, e.g. [email protected] (VPN required from most lab runners)}"
ssh -o BatchMode=yes "$CRM_PMX_SSH" \
"set -euo pipefail; cd '${RUNTIME_GIT_DIR}' && git fetch -q origin && git rev-parse HEAD && git merge-base --is-ancestor ${SHA_BIT881} HEAD && git merge-base --is-ancestor ${SHA_LIMIT} HEAD && echo ancestors_ok"
}
case "${1:-}" in
gitea) cmd_gitea ;;
runtime) cmd_runtime ;;
*)
echo "usage: $0 gitea|runtime" >&2
exit 1
;;
esac