Repository navigation
Conversation
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.
…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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4066
Proposed changes:
WP_Stream\Connector(Type the Connector family with all 22 children. xwp/stream#1983). The ActivityPub connector redeclares$nameand$actionswithout types, which now causes a fatal error when both plugins are active.$nameand$actionsin 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.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\Connectorhas no constructor today, so there is noparent::__construct()to call. If Stream adds one later, this constructor should call it.Other information:
Added
test_connector_does_not_redeclare_parent_properties, which uses reflection to assert that the connector does not redeclare any property ofWP_Stream\Connector. It fails ontrunkand passes with this change. The existingTest_Stream_Connectortests already checknameandactionson a real instance, and they still pass with the constructor.Testing instructions:
trunk.Type of Activitypub\Integration\Stream\Connector::$name must be stringis logged.Changelog entry
A changelog entry was added manually in
.github/changelog/fix-stream-typed-connector-properties.Changelog Entry Details
Significance
Type
Message
Fixed a fatal error when Stream 4.5.0 or newer is active.