Skip to content

Fix fatal error with Stream 4.5.0 typed connector properties - #4067

Open
desrosj wants to merge 2 commits into
Automattic:trunkfrom
desrosj:fix/stream-4-5-typed-connector-properties
Open

desrosj wants to merge 2 commits into
Automattic:trunkfrom
desrosj:fix/stream-4-5-typed-connector-properties

Conversation

@desrosj

@desrosj desrosj commented Nov 12, 2026 •

Copy link
Copy Markdown

Fixes #4066

Proposed changes:

  • Stream 4.5.0 added native types to the public properties of WP_Stream\Connector (Type the Connector family with all 22 children. xwp/stream#1983). The ActivityPub connector redeclares $name and $actions without types, which now causes a fatal error when both plugins are active.
  • This PR assigns $name and $actions in a constructor instead of redeclaring them. A redeclared property must match the parent's type, but assigning a value has no such check. So the connector loads with Stream versions before and after 4.5.0.
  • Just adding the types (public string $name, public array $actions) would fix Stream 4.5.0, but it would cause the reverse fatal error ("Type of ... must not be defined") on Stream 4.4.x and older.
  • WP_Stream\Connector has no constructor today, so there is no parent::__construct() to call. If Stream adds one later, this constructor should call it.

Other information:

  • Have you written new tests for your changes, if applicable?

Added test_connector_does_not_redeclare_parent_properties, which uses reflection to assert that the connector does not redeclare any property of WP_Stream\Connector. It fails on trunk and passes with this change. The existing Test_Stream_Connector tests already check name and actions on a real instance, and they still pass with the constructor.

Testing instructions:

  • Install and activate Stream 4.5.0 and ActivityPub from trunk.
  • Load any page and confirm the fatal error Type of Activitypub\Integration\Stream\Connector::$name must be string is logged.
  • Switch to this branch and confirm the site loads with no fatal error.
  • Under Stream > Settings, confirm the ActivityPub connector is listed. Trigger an ActivityPub event (for example, a new follower) and confirm it is logged in Stream.
  • Optionally, downgrade Stream to 4.4.0 and confirm this branch still loads and logs events.

Changelog entry

  • Automatically create a changelog entry from the details below.

A changelog entry was added manually in .github/changelog/fix-stream-typed-connector-properties.

Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Fixed a fatal error when Stream 4.5.0 or newer is active.

Stream 4.5.0 added native types to the public properties of
`WP_Stream\Connector`. Redeclaring `$name` and `$actions` without a type
now causes a fatal error, because PHP requires a redeclared property to
match the parent's type.

Assign the values in a constructor instead of redeclaring the properties,
so the connector works with Stream versions before and after 4.5.0.

Fixes Automattic#4066.
@github-actions github-actions Bot added [Focus] Compatibility Ensuring the plugin plays well with other plugins [Status] In Progress OSS Citizen labels Nov 12, 2026
…rties.

Redeclaring a property of `WP_Stream\Connector` causes a fatal error
whenever the child's type does not match the parent's, as happened with
the typed properties added in Stream 4.5.0. The test fails if the
connector redeclares any parent property.

See Automattic#4066.
@desrosj
desrosj marked this pull request as ready for review November 12, 2026 21:28
Copilot AI balanced review requested due to automatic review settings November 12, 2026 21:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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.

Fatal error with Stream 4.5.0: Type of Activitypub\Integration\Stream\Connector::$name must be string

2 participants