Skip to content

Fix the 5.0.11 update on Matomo versions before 5.9 and raise PHPStan to level 5 - #192

Merged
snake14 merged 2 commits into
5.x-devfrom
ratchet-phpstan-level-5
Sep 24, 2026
Merged

snake14 merged 2 commits into
5.x-devfrom
ratchet-phpstan-level-5

Conversation

@snake14

@snake14 snake14 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes the plugin's 5.0.11 update failing on Matomo versions before 5.9. It called settings methods that only exist from Matomo 5.9, so updating the plugin on an older Matomo 5 stopped with an error. The update now uses methods every supported Matomo 5 version has.

The fix edits the existing 5.0.11 update rather than adding a new one: on the affected versions the update fails before completing, and Matomo does not record it as done, so a later update would never be reached, and installs that already ran it are unaffected because it does the same thing. It now also writes through the same settings storage the 5.1.0 and 5.2.0 updates save from, so an install catching up on several updates at once keeps the value, and it does so without starting a cloud IP range sync during the update.

The rest of the change brings the 5.x branch into line with the shared plugin CI setup. The plugin now ships the shared pre-push hook and its created/modified PHPStan configs, and CI checks the hook against the canonical copy (verify-hook). The base PHPStan level rises from 0 to 5; the remaining findings are cleared without changing behaviour: two empty() checks that could never be false at that point, and four 'strlen' filters replaced with !== '' closures (the values are already trimmed strings).

Issue No

PG-4897

Steps to Replicate the Issue

  1. On Matomo 5.8 or earlier, with no block_headless value stored or configured, update TrackingSpamPrevention from a version before 5.0.11. The new tests in UpdatesTest cover the update, including 5.0.11 followed by 5.1.0 in one run.
  2. Expected: the update completes and block_headless is stored as disabled.
  3. Actual before this change: the update fails with "Call to undefined method PluginSettingsTable::loadValue()".

Checklist

  • [✔] Tested locally or on demo2/demo3?
  • [✔] New test case added/updated?
  • [NA] Are all newly added texts included via translation?
  • [NA] Are text sanitized properly? (Eg use of v-text v/s v-html for vue)
  • [✔] Version bumped?
  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules
  • [NA] Documentation updated?

…lease]

Clears the eight level-5 findings without changing behaviour: dead empty() checks, 'strlen' filters that return int, and the interface-typed settings backend in the 5.0.11 update.
loadValue()/saveValue() only exist on the settings backend from core 5.9. Check the stored rows with load() and write through the container's settings storage, so 5.1.0 and 5.2.0 in the same run can't write back a stale copy, without SystemSettings::save() starting a cloud IP sync.
@snake14 snake14 changed the title Ship the shared pre-push hook and raise PHPStan to level 5 [ignore_release] Fix the 5.0.11 update on Matomo versions before 5.9 and raise PHPStan to level 5 Sep 24, 2026
@snake14
snake14 enabled auto-merge (squash) September 24, 2026 05:39
@snake14
snake14 requested a review from a team September 24, 2026 05:39
@snake14
snake14 merged commit 494dc79 into 5.x-dev Sep 24, 2026
23 checks passed
@snake14
snake14 deleted the ratchet-phpstan-level-5 branch September 24, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants