From eddde2165ad5960e2470da02c31fdecb0876a514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drix?= Date: Fri, 15 May 2026 10:23:03 +0200 Subject: [PATCH] =?UTF-8?q?fix=20:=20run=5Fengine=5Fupdate=20v=C3=A9rifie?= =?UTF-8?q?=20origin=20=3D=3D=20folio=5Frepo=5Furl=20avant=20git=20pull?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- public/index.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/public/index.php b/public/index.php index 05f354e..13220e8 100644 --- a/public/index.php +++ b/public/index.php @@ -2823,7 +2823,18 @@ switch ($action) { exit; } - // 1. git pull + // 1. git pull — vérifier que origin pointe vers le dépôt folio configuré + $_folioRepo = rtrim(folioRepoUrl(), '/'); + exec('git -C ' . escapeshellarg(BASE_PATH) . ' remote get-url origin 2>&1', $_originOut, $_originCode); + $_originUrl = rtrim(trim(implode('', $_originOut)), '/'); + // Normaliser : supprimer les credentials éventuels de l'URL (token@host → host) + $_originNorm = preg_replace('#https?://[^@]+@#', 'https://', $_originUrl); + $_repoNorm = preg_replace('#https?://[^@]+@#', 'https://', $_folioRepo); + if ($_originCode !== 0 || $_originNorm !== $_repoNorm) { + $_SESSION['_update_log'] = "Le remote git 'origin' (" . $_originUrl . ") ne correspond pas à FOLIO_REPO_URL (" . $_folioRepo . "). git pull annulé."; + header('Location: /admin?tab=dashboard¬ice=update_git_error'); + exit; + } exec('cd ' . escapeshellarg(BASE_PATH) . ' && git pull origin main 2>&1', $_gitOut, $_gitCode); if ($_gitCode !== 0) { $_SESSION['_update_log'] = implode("\n", $_gitOut);