Problem/Motivation
Entity Share generates multiple PHP deprecation warnings related to implicitly marking parameters as nullable. These warnings indicate that the codebase needs to be updated to use explicit nullable types to comply with
modern PHP standards (PHP 8.4 promotes this to a deprecation notice, and it will become a fatal error in a future PHP major version). This is causing noise in logs and potential compatibility issues with newer PHP
versions.
The actively developed 4.x branch already includes related refactoring (e.g. changes to ImportConfigManipulator), but as of this writing 4.x is only at 4.0.0-alpha2, without stable release status
or security team coverage. The 3.x branch remains the recommended, security-covered release for production sites, so this issue proposes a minimal, low-risk fix targeted at 3.x rather than requiring sites to adopt an alpha
branch just to silence these deprecations.
Steps to reproduce
- Install Entity Share (8.x-3.x) on a Drupal site running PHP 8.4 or higher.
- Enable deprecated error logging in PHP configuration (e.g.
error_reporting(E_ALL | E_DEPRECATED)). - Clear cache with
drush crand trigger actions that exercise the affected services. - Observe deprecation notices such as:
- Deprecated: Drupal\entity_share_client\Service\ImportConfigManipulator::createImportProcessorPlugins(): Implicitly marking parameter $plugin_ids as nullable is deprecated, the explicit nullable type must be used
instead in /modules/entity_share_client/src/Service/ImportConfigManipulator.php on line 56 - Deprecated: Drupal\entity_share_client\Service\StateInformation::statusInfoArray(): Implicitly marking parameter $entity as nullable is deprecated ... in StateInformation.php on line 212
- Deprecated: Drupal\entity_share_client\Service\StateInformation::getImportStatusByParameters(): Implicitly marking parameter $langcode as nullable is deprecated ... in StateInformation.php on line 305
- Deprecated: Drupal\entity_share_client\Service\StateInformation::deleteImportStatusOfEntity(): Implicitly marking parameter $langcode as nullable is deprecated ... in StateInformation.php on line 339
- Deprecated: Drupal\entity_share_client\Plugin\Action\UpdatePolicyAction::access(): Implicitly marking parameter $account as nullable is deprecated ... in UpdatePolicyAction.php on line 107
- Deprecated: Drupal\entity_share_diff\Service\EntityParser::parseEntity(): Implicitly marking parameter $remote_data as nullable is deprecated ... in EntityParser.php on line 222
- Deprecated: Drupal\entity_share_client\Service\ImportConfigManipulator::createImportProcessorPlugins(): Implicitly marking parameter $plugin_ids as nullable is deprecated, the explicit nullable type must be used
Proposed resolution
Update Entity Share's 3.x codebase to use explicit nullable types (e.g. ?Type) for the affected parameters in the following files:
entity_share_client/src/Plugin/Action/UpdatePolicyAction.phpentity_share_client/src/Service/ImportConfigManipulator.phpentity_share_client/src/Service/StateInformation.phpentity_share_client/src/Service/StateInformationInterface.phpentity_share_client/tests/src/Functional/AuthenticationTestBase.phpentity_share_diff/src/Service/EntityParser.php
This will eliminate the deprecation warnings and ensure compatibility with PHP standards moving forward.
Remaining tasks
- Review and commit the attached patch to the 8.x-3.x branch.
- Confirm there are no other occurrences of the implicit-nullable pattern elsewhere in 3.x not covered by this patch.
- No new test coverage needed, since this only changes type declarations, not behavior.
User interface changes
None
API changes
None
Data model changes
None
Issue fork entity_share-3615155
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
nachosalvador commentedComment #4
jeffmattsonThis worked for me.
Comment #5
jeffmattson