From 3deb7fd74a47a31a7743ae9b6035610917a3a2e6 Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Mon, 12 Oct 2026 12:45:36 +0200 Subject: [PATCH] =?UTF-8?q?Konsole/Cronjobs:=20Besucher-Erkennung=20nur=20?= =?UTF-8?q?bei=20Web-Aufrufen=20(kein=20=E2=80=9Erequest=20object=20is=20n?= =?UTF-8?q?ot=20available=20in=20cli=E2=80=9C),=203.7.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- Changelog.md | 4 ++++ boot.php | 5 +++-- package.yml | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index 4c19491..f3193b1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Changelog +## [3.7.6] - 12.10.2026 + +- Konsole und Cronjobs (CLI) brechen nicht mehr mit „The request object is not available in cli“ ab: Die Besucher-Erkennung (`rex::getRequest()->getClientIp()`) läuft nur noch bei echten Web-Aufrufen. Betroffen waren u. a. Cronjobs in der Umgebung „Frontend“ und Konsolenbefehle anderer AddOns, die das Frontend booten. + ## [3.7.5] - 02.10.2026 - Cronjobs „Statistik-Hashes löschen“ und „Wartung“ werden jetzt in allen Umgebungen registriert; in der Umgebung „Frontend“ scheiterten sie bisher mit `Class "…" not found` (#157) diff --git a/boot.php b/boot.php index 1abd80e..c0fe1ff 100644 --- a/boot.php +++ b/boot.php @@ -64,7 +64,8 @@ // set variable to check in EP whether the visit is coming from a logged-in user or not -if (rex::isFrontend()) { +// (not on the command line: cronjobs/console have no request object, rex::getRequest() would throw) +if (rex::isFrontend() && 'cli' !== PHP_SAPI) { $addon = rex_addon::get('statistics'); $ignore_backend_loggedin = $addon->getConfig('statistics_ignore_backend_loggedin'); $identityMode = (string) $addon->getConfig('statistics_identity_mode', 'stateless'); @@ -133,7 +134,7 @@ // do actions after content is delivered rex_extension::register('RESPONSE_SHUTDOWN', function () use ($statistics_has_backend_login, $token) { - if (rex::isFrontend()) { + if (rex::isFrontend() && 'cli' !== PHP_SAPI) { $addon = rex_addon::get('statistics'); $trackingPaused = (bool) $addon->getConfig('statistics_pause_tracking_manual', false) diff --git a/package.yml b/package.yml index 4359577..dc6e0d7 100644 --- a/package.yml +++ b/package.yml @@ -1,5 +1,5 @@ package: statistics -version: 3.7.5 +version: 3.7.6 author: Andreas Lenhardt supportpage: https://github.com/AndiLeni/statistics