Problem/Motivation
After installing and enabling Private Content, Drush displays this deprecation warning:
[ec2-user@ip-172-31-45-186 drupal]$ drush status
PHP Deprecated: private_content_entity_field_access(): Implicitly marking parameter $items as nullable is deprecated, the explicit nullable type must be used instead in /var/www/drupal/web/modules/contrib/private_content/private_content.module on line 146
Drupal version : 11.3.2
Site URI : http://default
(etc)
Steps to reproduce
Install Private Content on a site with PHP 8.4.16
Proposed resolution
AI is proposing some solutions but I can't judge if this is a good solution or not, so I won't copy & paste it.
Remaining tasks
N/A
User interface changes
None
API changes
None
Data model changes
None
Issue fork private_content-3568184
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 #2
garvitasakhrani commentedI am working on it.
Comment #4
garvitasakhrani commentedFixed PHP 8.4 deprecation warning in private_content_entity_field_access(). Added explicit nullable type and $items check. Changes have been pushed to the fork branch 3568184-php-deprecated-warning.
Please review. Thanks!
Comment #6
batigolixThanks. We need to fix 2 other issues, before this one:
#2948622: Improve tests
#3563323: Make code pass gitlab pipeline
Comment #7
orkutmuratyilmazI'd like to add these line too:
PHP Deprecated: Drupal\private_content\Plugin\Field\FieldType\PrivateItemList::defaultAccess(): Implicitly marking parameter $account as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/web/modules/contrib/private_content/src/Plugin/Field/FieldType/PrivateItemList.php on line 19Comment #8
batigolixPlease review #2948622: Improve tests, so that there are unit tests before fixing the 8.4 warnings
Comment #9
batigolixComment #10
batigolixThis can be reviewed
Comment #11
arjenk commentedTested MR with php 8.4 and Drupal 11.3.
With the patch no more errors on 'drush status', also clicked through the 'private content' UI, and see no php warnings anymore.
Code looks good, adding '?' where needed. RTBC
Comment #13
batigolixComment #15
orkutmuratyilmazThanks for the fix:)