Skip to content

Fix admin bar migration bug for upgrading users#149

Merged
parhumm merged 1 commit intodevelopmentfrom
fix/issue-146-admin-bar-migration
Mar 9, 2026
Merged

Fix admin bar migration bug for upgrading users#149
parhumm merged 1 commit intodevelopmentfrom
fix/issue-146-admin-bar-migration

Conversation

@ParhamTehrani
Copy link
Copy Markdown
Contributor

@ParhamTehrani ParhamTehrani commented Mar 9, 2026

Added version-gated migration for 5.4.1 to ensure 'use_separate_menu' setting is properly set to 'on' for users upgrading from older versions where the empty() check failed for the string 'no'.

Close #146

Describe your changes

...

Submission Review Guidelines:

  • I have performed a self-review of my code
  • If it is a core feature, I have added thorough tests.
  • Will this be part of a product update? If yes, please write one phrase about this update.
  • I have reviewed my code for security best practices.
  • Following the above guidelines will result in quick merges and clear and detailed feedback when appropriate.
  • My code follows the style guidelines of this project
  • I have updated the change-log in CHANGELOG.md.

Type of change

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Summary by CodeRabbit

  • Bug Fix

    • Admin bar "Online: X" counter now appears correctly after upgrading from older versions.
  • Chores

    • Added 5.4.1 release notes and bumped the plugin version.
    • Improved the upgrade/migration so the menu-related setting is initialized during updates to 5.4.1.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 9, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Adds a version-gated migration in the updater to set use_separate_menu = 'on' for upgrades to 5.4.1, and updates release metadata (CHANGELOG, readme, plugin header/version constant) to 5.4.1.

Changes

Cohort / File(s) Summary
Migration / Admin
admin/index.php
In the 5.4.0+ update sequence, add a conditional migration that sets use_separate_menu to 'on' for installs upgrading to 5.4.1 when the stored version is older than 5.4.1.
Release Notes
CHANGELOG.md, readme.txt
Add a 5.4.1 changelog entry describing the fix for the admin bar "Online: X" counter and bump the stable tag to 5.4.1.
Plugin Version
wp-slimstat.php
Update plugin header version and SLIMSTAT_ANALYTICS_VERSION constant from 5.4.0 to 5.4.1.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰
Hopped a patch across the lea,
Turned the menu switch to "on" with glee,
Old installs now see the Online light,
Admin bar springs back into sight 🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix admin bar migration bug for upgrading users' directly and clearly summarizes the main change: a migration fix that addresses the admin bar visibility issue for users upgrading from older versions.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #146: adds version-gated migration for <5.4.1 that sets use_separate_menu='on', bumps version constants to 5.4.1 to trigger migration, and includes changelog updates.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the stated objectives: migration logic, version bumps, and documentation updates related to the admin bar fix for issue #146.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/issue-146-admin-bar-migration

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@admin/index.php`:
- Around line 735-738: Limit the migration so it only affects legacy upgrades
and doesn't overwrite explicit user choices: in update_tables_and_options()
change the condition that currently sets
wp_slimstat::$settings['use_separate_menu'] for versions < '5.4.1' to instead
run only for versions before the admin-bar redesign (e.g.,
version_compare(wp_slimstat::$settings['version'], '5.4.0', '<')), and only
assign 'on' when the key is missing or clearly a legacy/empty value (check
!isset(wp_slimstat::$settings['use_separate_menu']) ||
wp_slimstat::$settings['use_separate_menu'] === '' or other legacy sentinel) so
existing explicit 'no' values are preserved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 44b915ef-3f0f-4db7-9fe7-592137289faf

📥 Commits

Reviewing files that changed from the base of the PR and between 8aa7660 and 92c8177.

📒 Files selected for processing (1)
  • admin/index.php

@ParhamTehrani ParhamTehrani force-pushed the fix/issue-146-admin-bar-migration branch from 92c8177 to 3aae654 Compare March 9, 2026 14:27
@parhumm
Copy link
Copy Markdown
Contributor

parhumm commented Mar 9, 2026

Review: Version gate needs adjustment

Issue: < '5.4.0' misses users already on 5.4.0

The current condition:

if (version_compare(wp_slimstat::$settings['version'], '5.4.0', '<') && wp_slimstat::$settings['use_separate_menu'] === 'no') {

Only catches users on 5.3.x and older. Users who already updated to 5.4.0 (and ran the broken empty() migration) have stored version '5.4.0' — so version_compare('5.4.0', '5.4.0', '<') is false and they're never fixed.

Fix

Change to:

if (version_compare(wp_slimstat::$settings['version'], '5.4.1', '<')) {
    wp_slimstat::$settings['use_separate_menu'] = 'on';
}

Why this works:

  • < '5.4.1' catches both pre-5.4.0 users and 5.4.0 users who ran the broken migration
  • The === 'no' check isn't needed — this migration runs once (version gets bumped to 5.4.1 at line 736 right after, preventing re-runs). Users who later disable it manually will already be on 5.4.1+, so this block never fires again.

Also needed

This fix requires bumping SLIMSTAT_ANALYTICS_VERSION to '5.4.1' so the migration trigger at admin/index.php:210 (SLIMSTAT_ANALYTICS_VERSION != stored version) fires for users already on 5.4.0. Version bump locations:

File Line Change
wp-slimstat.php 6 Plugin header Version:5.4.1
wp-slimstat.php 23 SLIMSTAT_ANALYTICS_VERSION'5.4.1'
readme.txt 8 Stable tag:5.4.1

@ParhamTehrani ParhamTehrani force-pushed the fix/issue-146-admin-bar-migration branch from 3aae654 to e595990 Compare March 9, 2026 14:36
Added version-gated migration for 5.4.1 to ensure 'use_separate_menu'
setting is properly set to 'on' for users upgrading from older versions
where the empty() check failed for the string 'no'.

Fixes #146
@ParhamTehrani ParhamTehrani force-pushed the fix/issue-146-admin-bar-migration branch from e595990 to c5db37d Compare March 9, 2026 14:40
@parhumm parhumm merged commit af50638 into development Mar 9, 2026
1 check was pending
@parhumm parhumm deleted the fix/issue-146-admin-bar-migration branch March 9, 2026 14:42
@coderabbitai coderabbitai bot mentioned this pull request Mar 9, 2026
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