Repository navigation
Conversation
…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
[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.
|
| 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 ); |
There was a problem hiding this 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.
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!
…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.