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

Command icon 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

guusbosman created an issue. See original summary.

garvitasakhrani’s picture

Assigned: Unassigned » garvitasakhrani

I am working on it.

garvitasakhrani’s picture

Assigned: garvitasakhrani » Unassigned
Status: Active » Needs review

Fixed 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!

batigolix made their first commit to this issue’s fork.

batigolix’s picture

Status: Needs review » Postponed

Thanks. We need to fix 2 other issues, before this one:

#2948622: Improve tests
#3563323: Make code pass gitlab pipeline

orkutmuratyilmaz’s picture

I'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 19

batigolix’s picture

Please review #2948622: Improve tests, so that there are unit tests before fixing the 8.4 warnings

batigolix’s picture

Priority: Minor » Major
Issue tags: +finalist-sprint
batigolix’s picture

Status: Postponed » Needs review

This can be reviewed

arjenk’s picture

Status: Needs review » Reviewed & tested by the community

Tested 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

batigolix’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

orkutmuratyilmaz’s picture

Thanks for the fix:)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.