Skip to content

fix(profile): guard the logout cookie name in the profile module's own logout too - #198

Merged
mambax7 merged 1 commit into
XOOPS:masterfrom
mambax7:fix/profile-logout-cookie-name
Sep 10, 2026
Merged

fix(profile): guard the logout cookie name in the profile module's own logout too#198
mambax7 merged 1 commit into
XOOPS:masterfrom
mambax7:fix/profile-logout-cookie-name

Conversation

@mambax7

@mambax7 mambax7 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

#195 guarded the remember-me cookie clearing on logout in user.php, but the profile module's user.php carries its own logout with the same two unguarded calls and is reached directly, so a site with remember-me disabled still failed on logout through that page. The same guard is applied there, and LogoutCookieNameGuardTest now covers both logout pages.

The 2.7.4 Beta 1 release note for this fix named the users admin as a guarded path; it clears no cookie. The note now names the two logout pages and the session restore. Both points were raised on #197 after it merged.

Tests

The profile case failed before the guard and passes after; removing the guard fails it again. tests/ at baseline on PHP 8.4.

Summary by Sourcery

Prevent logout failures when remember-me cookies are disabled across both logout entry points.

Bug Fixes:

  • Guard remember-me cookie clearing in the profile module’s logout path when no cookie name is configured.

Documentation:

  • Correct the release note to identify both logout pages and session restoration as covered by the fix.

Tests:

  • Extend logout cookie guard coverage to both the core and profile logout entry points.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed logout behavior when the remember-me cookie setting is not configured.
    • The cookie is now cleared only when a cookie name is configured.
    • Applied consistently when logging out through the main user page and profile module.
    • Session restoration behavior and release documentation now accurately reflect these conditions.

…n logout too

XOOPS#195 guarded the remember-me cookie clearing on logout in user.php, but
the profile module's user.php carries its own logout with the same two
unguarded calls and is reached directly, so a site with remember-me
disabled still failed on logout through that page. The same guard is
applied there, and the regression test now covers both logout pages.

The 2.7.4 Beta 1 release note for this fix named the users admin as a
guarded path; it clears no cookie. The note now names the two logout
pages and the session restore.
Copilot AI lite review requested due to automatic review settings September 10, 2026 04:05
@sourcery-ai

sourcery-ai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The PR fixes logout when remember-me is disabled by guarding the profile module’s duplicate cookie-clearing calls, expands the source-based regression test to cover both logout implementations, and corrects the release-note wording for the affected paths.

Sequence diagram for guarded logout cookie clearing

sequenceDiagram
    participant User
    participant LogoutPage
    participant Session
    participant Cookie

    User->>LogoutPage: logout
    LogoutPage->>Session: regenerate_id(true)
    LogoutPage->>Session: clear session
    alt usercookie is configured
        LogoutPage->>Cookie: xoops_setcookie(usercookie, null, expiry, /, domain, 0)
        LogoutPage->>Cookie: xoops_setcookie(usercookie, null, expiry, /)
    end
    LogoutPage-->>User: logout completes
Loading

File-Level Changes

Change Details Files
Guard remember-me cookie deletion in the profile module’s direct logout flow.
  • Wrap both cookie-clearing calls in a non-empty cookie-name check.
  • Preserve existing cookie paths, domain, and expiration behavior when configured.
htdocs/modules/profile/user.php
Extend regression coverage to both logout entry points.
  • Add a data provider for the core and profile logout source files.
  • Reuse the existing assertion that cookie clearing is conditional on a configured name.
tests/unit/htdocs/LogoutCookieNameGuardTest.php
Correct the 2.7.4 Beta 1 release note to describe the affected logout paths.
  • Replace the incorrect users-admin reference with the two logout pages and session restore.
docs/changelog.270.txt

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 7faa5e23-6332-41b1-9792-56a82e91406e

📥 Commits

Reviewing files that changed from the base of the PR and between feb6767 and 44e39c5.

📒 Files selected for processing (3)
  • docs/changelog.270.txt
  • htdocs/modules/profile/user.php
  • tests/unit/htdocs/LogoutCookieNameGuardTest.php

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The profile logout handler now clears the remember-me cookie only when a cookie name is configured. The regression test covers both core and profile logout entry points. The changelog describes the corrected behavior.

Changes

Remember-me cookie logout guard

Layer / File(s) Summary
Guard logout cookie clearing and validate both entry points
htdocs/modules/profile/user.php, tests/unit/htdocs/LogoutCookieNameGuardTest.php, docs/changelog.270.txt
The profile logout path checks usercookie before calling xoops_setcookie(). The test uses a data provider for the core and profile logout pages. The changelog reflects the guarded behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 44e39

Logout now avoids attempting to clear an unnamed remember-me cookie in the profile flow while retaining configured-cookie behavior. The change is covered for both logout pages and is ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: guarding remember-me cookie deletion in the profile module's logout flow.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 PHPStan (2.2.9)

PHP Fatal error: Uncaught Error: Class "Nette\DI\ServiceCreationException" not found in /.cache/phpstan/phpstan/cache/nette.configurator/Container_cbb1c40a91.php:8719
Stack trace:
#0 phar:///usr/bin/phpstan/vendor/nette/di/src/DI/Container.php(51): Container_cbb1c40a91->getDynamicParameter()
#1 phar:///usr/bin/phpstan/vendor/nette/di/src/DI/Container.php(245): _PHPStan_eca38da41\Nette\DI\Container->_PHPStan_eca38da41\Nette\DI{closure}()
#2 phar:///usr/bin/phpstan/vendor/nette/di/src/DI/Container.php(50): _PHPStan_eca38da41\Nette\DI\Container->preventDeadLock()
#3 [internal function]: _PHPStan_eca38da41\Nette\DI\Container->getParameter()
#4 /.cache/phpstan/phpstan/cache/nette.configurator/Container_cbb1c40a91.php(8732): array_map()
#5 phar:///usr/bin/phpstan/src/DependencyInjection/Nette/NetteContainer.php(94): Container_cbb1c40a91->getParameters()
#6 phar:///usr/bin/phpstan/src/DependencyInjection/MemoizingContainer.php(57): PHPStan\DependencyInjection\Nette\NetteContainer->getParame

... [truncated 2695 characters] ...

Stan\Command\AnalyseCommand->execute()
#11 phar:///usr/bin/phpstan/vendor/symfony/console/Application.php(868): _PHPStan_eca38da41\Symfony\Component\Console\Command\Command->run()
#12 phar:///usr/bin/phpstan/vendor/symfony/console/Application.php(261): _PHPStan_eca38da41\Symfony\Component\Console\Application->doRunCommand()
#13 phar:///usr/bin/phpstan/vendor/symfony/console/Application.php(157): _PHPStan_eca38da41\Symfony\Component\Console\Application->doRun()
#14 phar:///usr/bin/phpstan/bin/phpstan(94): _PHPStan_eca38da41\Symfony\Component\Console\Application->run()
#15 phar:///usr/bin/phpstan/bin/phpstan(95): _PHPStan_eca38da41{closure}()
#16 /usr/bin/phpstan(7): require('...')
#17 {main}
thrown in /.cache/phpstan/phpstan/cache/nette.configurator/Container_cbb1c40a91.php on line 8719


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/unit/htdocs/LogoutCookieNameGuardTest.php" line_range="58" />
<code_context>
     #[Test]
-    public function logoutClearsTheRememberMeCookieOnlyWhenANameIsConfigured(): void
+    #[DataProvider('logoutPages')]
+    public function logoutClearsTheRememberMeCookieOnlyWhenANameIsConfigured(string $file): void
     {
-        $this->loadSourceFile('htdocs/user.php');
</code_context>
<issue_to_address>
**issue (testing):** The regression test only scans the logout source text and never executes either logout path, so it can pass even when the runtime guard does not actually prevent `xoops_setcookie()` from being called with an empty configured name.

**Triggers:** When a future edit preserves the expected source strings but changes the runtime condition, control flow, or included code.

**Suggested fix:** Execute each logout source file with an empty and a configured `usercookie` value, asserting that the cookie helper is respectively not called and called twice.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and if the guard were wrong for configured cookie names, logout could leave a remember-me cookie in the browser and allow the account to be restored after logout. Reverting would fix future logouts, but cookies already left behind could remain usable until they expire or are otherwise cleared.

Blocking findings: tests/unit/htdocs/LogoutCookieNameGuardTest.php:58


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

#[Test]
public function logoutClearsTheRememberMeCookieOnlyWhenANameIsConfigured(): void
#[DataProvider('logoutPages')]
public function logoutClearsTheRememberMeCookieOnlyWhenANameIsConfigured(string $file): void

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (testing): The regression test only scans the logout source text and never executes either logout path, so it can pass even when the runtime guard does not actually prevent xoops_setcookie() from being called with an empty configured name.

Triggers: When a future edit preserves the expected source strings but changes the runtime condition, control flow, or included code.

Suggested fix: Execute each logout source file with an empty and a configured usercookie value, asserting that the cookie helper is respectively not called and called twice.

@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no actionable defects identified in the changed behavior.

Summary

  • Applies the existing cookie-name guard to both cookie-clearing calls in the profile logout path.
  • Extends the logout guard test to cover both core and profile logout entry points.
  • Corrects the 2.7.4 Beta 1 changelog description.

Reviews (1) · Last reviewed commit: "fix(profile): guard the logout cookie na..."

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped, matches the established guard pattern, and is backed by an updated regression test covering both logout entry points.

Pull request overview

This pull request closes the remaining logout failure when “remember-me” is disabled by applying the same cookie-name guard to the profile module’s direct logout entry point, and extends the existing regression test to cover both logout pages. It also corrects the 2.7.4 Beta 1 release note to reflect the actual guarded paths.

Changes:

  • Guard xoops_setcookie() calls in modules/profile/user.php so logout doesn’t attempt to clear a cookie with an empty name.
  • Extend LogoutCookieNameGuardTest to run against both htdocs/user.php and htdocs/modules/profile/user.php.
  • Update the 2.7.4 Beta 1 changelog entry to name the two logout pages plus session restore (and remove the incorrect users-admin mention).
File summaries
File Description
tests/unit/htdocs/LogoutCookieNameGuardTest.php Adds a data provider so the existing guard assertion runs against both logout entry points.
htdocs/modules/profile/user.php Wraps remember-me cookie clearing in an !empty(usercookie) guard to prevent PHP 8+ empty-cookie-name errors.
docs/changelog.270.txt Corrects the release note wording to match the guarded logout/restore paths.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@gitar-bot

gitar-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.63%. Comparing base (ea4627f) to head (44e39c5).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
htdocs/modules/profile/user.php 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #198      +/-   ##
============================================
- Coverage     20.63%   20.63%   -0.01%     
  Complexity     7995     7995              
============================================
  Files           675      675              
  Lines         43514    43515       +1     
============================================
  Hits           8981     8981              
- Misses        34533    34534       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mambax7
mambax7 merged commit 8b4b206 into XOOPS:master Sep 10, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants