From 123de698aaa27de999e8dd390bd001a016b301ac Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 8 Jun 2026 13:33:07 -0700 Subject: [PATCH 1/6] Restore logging consent of anonymous users --- service/log_manager.php | 11 ++++------- tests/functional/frontend_test.php | 4 ++-- tests/service/log_manager_test.php | 10 ++++++++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/service/log_manager.php b/service/log_manager.php index 333ba11..a73f31b 100644 --- a/service/log_manager.php +++ b/service/log_manager.php @@ -54,11 +54,6 @@ public function __construct(config $config, driver_interface $db, user $user, $c */ public function log_consent(array $categories, $version) { - if ((int) $this->user->data['user_id'] === ANONYMOUS) - { - return; - } - $record = [ 'anonymized_id' => $this->get_anonymized_subject(), 'consent_version' => (int) $version, @@ -71,12 +66,14 @@ public function log_consent(array $categories, $version) } /** - * Build an anonymized identifier for the current authenticated user. + * Build an anonymized identifier for the current user or session. * * @return string */ protected function get_anonymized_subject() { - return hash_hmac('sha256', 'u:' . (int) $this->user->data['user_id'], $this->config['rand_seed']); + $subject = (int) $this->user->data['user_id'] !== ANONYMOUS ? 'u:' . (int) $this->user->data['user_id'] : 's:' . $this->user->session_id; + + return hash_hmac('sha256', $subject, $this->config['rand_seed']); } } diff --git a/tests/functional/frontend_test.php b/tests/functional/frontend_test.php index 6457fb6..873a008 100644 --- a/tests/functional/frontend_test.php +++ b/tests/functional/frontend_test.php @@ -61,7 +61,7 @@ public function test_log_endpoint_rejects_invalid_json_payload() ), json_decode(self::$client->getResponse()->getContent(), true)); } - public function test_log_endpoint_accepts_valid_anonymous_submission_without_persisting_it() + public function test_log_endpoint_persists_valid_anonymous_submission() { $payload = $this->fetch_frontend_payload(); $response = $this->post_log_request($payload, array('analytics', 'analytics', 'unknown')); @@ -76,7 +76,7 @@ public function test_log_endpoint_accepts_valid_anonymous_submission_without_per $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); - $this->assertSame(0, (int) $row['log_count']); + $this->assertSame(1, (int) $row['log_count']); } public function test_log_endpoint_persists_valid_authenticated_submission() diff --git a/tests/service/log_manager_test.php b/tests/service/log_manager_test.php index bcfc4a0..71fd43d 100644 --- a/tests/service/log_manager_test.php +++ b/tests/service/log_manager_test.php @@ -56,12 +56,18 @@ public function test_log_consent_persists_authenticated_subject() FROM phpbb_consentmanager_logs'); } - public function test_log_consent_skips_guests() + public function test_log_consent_uses_session_identifier_for_guests() { $manager = $this->create_manager(ANONYMOUS, 'guest-session'); $manager->log_consent(array('necessary'), 9); - $this->assertSqlResultEquals(array(), 'SELECT anonymized_id, consent_version, accepted_categories + $this->assertSqlResultEquals(array( + array( + 'anonymized_id' => hash_hmac('sha256', 's:guest-session', 'random-seed'), + 'consent_version' => '9', + 'accepted_categories' => '["necessary"]', + ), + ), 'SELECT anonymized_id, consent_version, accepted_categories FROM phpbb_consentmanager_logs'); } From 88be74de99b45e9d762155d14b437ff9314d32da Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 8 Jun 2026 13:51:28 -0700 Subject: [PATCH 2/6] Add privacy policy link to banner and modal --- language/en/common.php | 1 + styles/all/template/event/overall_footer_body_after.html | 3 ++- styles/all/theme/consentmanager.css | 7 +++++++ tests/functional/frontend_test.php | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/language/en/common.php b/language/en/common.php index a7a8a81..08d5de7 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -30,6 +30,7 @@ 'CONSENTMANAGER_DEFAULT_BANNER_TITLE' => 'We value your privacy', 'CONSENTMANAGER_DEFAULT_BANNER_TEXT' => 'This forum uses cookies to keep you signed in, secure your account, and ensure the site works properly. With your consent, we may also use optional cookies and similar technologies for analytics, marketing, and embedded media.', 'CONSENTMANAGER_DEFAULT_BANNER_SUBTEXT' => 'You can change your preferences at any time in the Privacy Settings.', + 'CONSENTMANAGER_PRIVACY_POLICY_LINK' => 'Read our full %s.', 'CONSENTMANAGER_CATEGORY_NECESSARY' => 'Necessary', 'CONSENTMANAGER_CATEGORY_NECESSARY_EXPLAIN' => 'Required for forum security, authentication, and essential site functionality.', 'CONSENTMANAGER_CATEGORY_ANALYTICS' => 'Analytics', diff --git a/styles/all/template/event/overall_footer_body_after.html b/styles/all/template/event/overall_footer_body_after.html index a20cc30..9d45515 100644 --- a/styles/all/template/event/overall_footer_body_after.html +++ b/styles/all/template/event/overall_footer_body_after.html @@ -2,7 +2,7 @@