Skip to content

CU-z8zyy1rdhq fix: run only pending upgrades and record current plugi… - #47

Open
eug-L wants to merge 1 commit into
masterfrom
fix/upgrade-manager
Open

eug-L wants to merge 1 commit into
masterfrom
fix/upgrade-manager

Conversation

@eug-L

@eug-L eug-L commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

…n version

The upgrade manager stored each upgrade's version instead of the current plugin version, so tawkto-version stayed at 0.9.0 and the upgrades re-ran on every request. The 0.9.0 upgrade then reset the Javascript API key, breaking Secure Mode for logged-in visitors.

  • Only run upgrades newer than the stored version and up to the current one
  • Store the current plugin version once after the upgrades run
  • Only initialise the security option in the 0.9.0 upgrade if it is missing
  • Add 0.9.4 changelog entry

…n version

The upgrade manager stored each upgrade's version instead of the current
plugin version, so tawkto-version stayed at 0.9.0 and the upgrades re-ran
on every request. The 0.9.0 upgrade then reset the Javascript API key,
breaking Secure Mode for logged-in visitors.

- Only run upgrades newer than the stored version and up to the current one
- Store the current plugin version once after the upgrades run
- Only initialise the security option in the 0.9.0 upgrade if it is missing
- Add 0.9.4 changelog entry
@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect the plugin’s upgrade flow and logged-in visitor recognition.

The PR appears safe to merge; adding regression tests is recommended.

Fix All in Claude CodeFindings

  1. P2 Upgrade fixes lack regression tests ▶
Fix with agent prompt
### Issue 1
tawkto/upgrade.manager.php:64-71
No existing tests exercise `TawkToUpgradeManager` or either upgrade. Add coverage for an empty stored version, stored `0.9.0` with current `0.9.4`, and a second request after upgrading. Assert which upgrades run, that `tawkto-version` becomes the current version, and that an existing `js_api_key` survives. Without these checks, repeated upgrades and key resets could return unnoticed.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR stops completed upgrades from running again and preserves saved JavaScript API keys.

  • The upgrade manager records the installed version after running its steps.
  • The 0.9.0 upgrade keeps an existing JavaScript API key.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read stored and current versions] --> B{Stored version is current or newer?}
  B -- Yes --> C[Stop]
  B -- No --> D[Run pending registered upgrades]
  D --> E[Preserve existing security settings]
  E --> F[Save current plugin version]
Loading

Reviews (1) · Last reviewed commit: "CU-z8zyy1rdhq fix: run only pending upgr..." · Reviewed by Greptile

Comment on lines +64 to +71
foreach ( $this->upgrades as $upgrade_ver => $upgrade ) {
if ( version_compare( $upgrade_ver, $this->prev_ver ) > 0 &&
version_compare( $upgrade_ver, $this->curr_ver ) <= 0 ) {
$this->do_upgrade( $upgrade_ver );
}
}

update_option( $this->version_var_name, $this->curr_ver );

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Upgrade fixes lack regression tests

No existing tests exercise TawkToUpgradeManager or either upgrade. Add coverage for an empty stored version, stored 0.9.0 with current 0.9.4, and a second request after upgrading. Assert which upgrades run, that tawkto-version becomes the current version, and that an existing js_api_key survives. Without these checks, repeated upgrades and key resets could return unnoticed.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tawkto/upgrade.manager.php
Line: 64-71

Comment:
**Upgrade fixes lack regression tests**

No existing tests exercise `TawkToUpgradeManager` or either upgrade. Add coverage for an empty stored version, stored `0.9.0` with current `0.9.4`, and a second request after upgrading. Assert which upgrades run, that `tawkto-version` becomes the current version, and that an existing `js_api_key` survives. Without these checks, repeated upgrades and key resets could return unnoticed.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Cursor Fix in Codex

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.

1 participant