From 36e423d5fbb62ff294f430e25a3da1fa3ac78d4f Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 12 Nov 2026 15:51:03 -0500 Subject: [PATCH 1/3] Stream: Fix fatal error with Stream 4.5.0 typed connector properties. 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 #4066. --- .../fix-stream-typed-connector-properties | 4 +++ integration/stream/class-connector.php | 29 +++++++++---------- 2 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 .github/changelog/fix-stream-typed-connector-properties diff --git a/.github/changelog/fix-stream-typed-connector-properties b/.github/changelog/fix-stream-typed-connector-properties new file mode 100644 index 0000000000..d84bd32e28 --- /dev/null +++ b/.github/changelog/fix-stream-typed-connector-properties @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fixed a fatal error when Stream 4.5.0 or newer is active. diff --git a/integration/stream/class-connector.php b/integration/stream/class-connector.php index 5aaafda1ea..6c6ef1946e 100644 --- a/integration/stream/class-connector.php +++ b/integration/stream/class-connector.php @@ -22,23 +22,22 @@ */ class Connector extends \WP_Stream\Connector { /** - * Connector slug. + * Set the connector slug and the actions registered for this connector. * - * @var string + * These are assigned here rather than redeclared as properties. Stream 4.5.0 + * added native types to the parent class properties, and PHP requires a + * redeclared property to match the parent's type exactly. Assigning them + * keeps the connector compatible with Stream versions before and after 4.5.0. */ - public $name = 'activitypub'; - - /** - * Actions registered for this connector. - * - * @var array - */ - public $actions = array( - 'activitypub_handled_follow', - 'activitypub_sent_to_inbox', - 'activitypub_outbox_processing_complete', - 'activitypub_outbox_processing_batch_complete', - ); + public function __construct() { + $this->name = 'activitypub'; + $this->actions = array( + 'activitypub_handled_follow', + 'activitypub_sent_to_inbox', + 'activitypub_outbox_processing_complete', + 'activitypub_outbox_processing_batch_complete', + ); + } /** * Return translated connector label. From fddacde470e43d4f974d043609a6d3d9ad56a515 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:27:27 -0500 Subject: [PATCH 2/3] Stream: Add a test that the connector does not redeclare parent properties. 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 #4066. --- .../class-test-stream-connector.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/phpunit/tests/integration/class-test-stream-connector.php b/tests/phpunit/tests/integration/class-test-stream-connector.php index 9b12848987..6db05d53bb 100644 --- a/tests/phpunit/tests/integration/class-test-stream-connector.php +++ b/tests/phpunit/tests/integration/class-test-stream-connector.php @@ -696,6 +696,33 @@ public function test_prepare_outbox_data_for_response_blog_user_url() { public function test_class_hierarchy() { $this->assertInstanceOf( '\WP_Stream\Connector', $this->stream_connector ); } + + /** + * Test that the connector does not redeclare properties of the parent class. + * + * Stream 4.5.0 added native types to the properties of WP_Stream\Connector. + * A child class that redeclares one of them must use the same type, which + * would break older Stream versions where the properties are untyped. The + * connector must assign these values instead of redeclaring them. + * + * @see https://github.com/Automattic/wordpress-activitypub/issues/4066 + * + * @covers ::__construct + */ + public function test_connector_does_not_redeclare_parent_properties() { + $parent_class = \get_parent_class( Connector::class ); + $parent = new \ReflectionClass( $parent_class ); + + foreach ( $parent->getProperties() as $parent_property ) { + $property = new \ReflectionProperty( Connector::class, $parent_property->getName() ); + + $this->assertSame( + $parent->getName(), + $property->getDeclaringClass()->getName(), + \sprintf( 'Connector must not redeclare the parent property $%s.', $parent_property->getName() ) + ); + } + } } // Mock WP_Stream\Connector if it doesn't exist. From 0ff68b3c300b4fde81341cb22e8919e8cfc2407f Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Fri, 13 Nov 2026 09:31:42 +0100 Subject: [PATCH 3/3] Update tests/phpunit/tests/integration/class-test-stream-connector.php --- tests/phpunit/tests/integration/class-test-stream-connector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/integration/class-test-stream-connector.php b/tests/phpunit/tests/integration/class-test-stream-connector.php index 6db05d53bb..144b69b030 100644 --- a/tests/phpunit/tests/integration/class-test-stream-connector.php +++ b/tests/phpunit/tests/integration/class-test-stream-connector.php @@ -713,7 +713,7 @@ public function test_connector_does_not_redeclare_parent_properties() { $parent_class = \get_parent_class( Connector::class ); $parent = new \ReflectionClass( $parent_class ); - foreach ( $parent->getProperties() as $parent_property ) { + foreach ( $parent->getProperties( \ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED ) as $parent_property ) { $property = new \ReflectionProperty( Connector::class, $parent_property->getName() ); $this->assertSame(