Skip to content

fix: index crash with hidebots enabled; phpBB 4.0 coding standard - #23

Merged
bonelifer merged 1 commit into
masterfrom
fix/optional-listener-types
Nov 5, 2026
Merged

bonelifer merged 1 commit into
masterfrom
fix/optional-listener-types

Conversation

@bonelifer

Copy link
Copy Markdown
Contributor

First pass on activity24hours as a phpbbmodders extension: a crash fix plus the phpBB 4.0 baseline.

Crash with hidebots enabled. The listener type-hinted its optional services as hidebots $hidebots = null and relativedates $relativedates = null without importing those classes, so PHP expected classes inside this extension's namespace. With hidebots enabled, every index page failed:

Argument #9 ($hidebots) must be of type ?rmcgirr83\activity24hours\event\hidebots, rmcgirr83\hidebots\event\listener given

Both are now object|null. The same change also clears two PHP 8 deprecations: an optional parameter before a required one, and an implicitly nullable type.

phpBB 4.0. The 3.3.19 minimum was already in place and there is no 4.0 ceiling. The events, template events and core classes the extension uses all exist on phpBB master. This PR also:

  • declares $lookback instead of creating it as a dynamic property (deprecated since PHP 8.2);
  • writes public static instead of static public, which phpBB 4.0's code sniffer requires.

Guest report. docs/BUGS.md listed a support topic where guests could not see who is online. On both test boards, phpBB's "Who is online" block was the same with this extension enabled and disabled. Guests see usernames there only with the core permission "Can view profiles, memberlist and online list"; the reporter had set "Can view hidden online users". The extension's own block needs its own permission, which the install does not give to guests. The README now explains both, and the entry is removed from docs/BUGS.md.

Testing. Claude ran the new feature_checks.py activity24hours check (phpbbmodders/phpbb-release-tools, separate PR) on seed-forum boards with phpBB 3.3.19 and phpBB master, both SQLite, with hidebots mounted:

  • This branch: 10/10 on both boards, run twice on each. The admin sees the block, guests see it only with its permission, the index loads with hidebots enabled, no PHP errors, and disable/purge/enable works.
  • The old listener: with hidebots enabled the index returns HTTP 500 for guests and the admin on both boards.

phpcs passes with the 3.3.x and 4.0 extension rulesets, and PHP lint passes on 8.3 and 8.4 with --strict.


Investigated and written by Claude on behalf of William Jacoby (bonelifer).

🤖 Generated with Claude Code

The listener type-hinted its optional hidebots and relativedates services
with class names that were never imported, so PHP expected classes in this
extension's namespace. With hidebots enabled, every index page failed with
a TypeError. Both are now plain object|null.

Also declares the lookback property instead of creating it dynamically,
moves static after public for phpBB 4.0's code sniffer, documents who
sees the activity block, and drops the guest report from docs/BUGS.md:
it is a core permission setting, not this extension.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bonelifer
bonelifer merged commit 39bf8f1 into master Nov 5, 2026
2 checks passed
@bonelifer
bonelifer deleted the fix/optional-listener-types branch November 5, 2026 14:39
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