Problem/Motivation

The module throws an error when running php 8.1. Seems like all that needs to be done is to add a return type to the noted count() method.

Issue fork entity-3249372

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:

  • 3249372-php-8.1- Comparecompare

Comments

mrweiner created an issue. See original summary.

mrweiner’s picture

Status: Active » Needs review

I don't know what's going on with the issue fork or why the MR isn't showing up in here, but it's at https://git.drupalcode.org/issue/entity-3249372/-/merge_requests/1.

tr’s picture

I suspect this will fail in PHP 7. Maybe upload this as a regular patch so we can get the tests run.

aardwolf’s picture

StatusFileSize
new723 bytes

Here's a patch file from MR.
Author of this mrweiner.

Status: Needs review » Needs work

The last submitted patch, 4: 3249372-4.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tr’s picture

Status: Needs work » Reviewed & tested by the community

The 14 test failures are branch failures, unrelated to this patch. Those should really be fixed, but they happen because this module adds a drupalci.yml that deliberately fails when it encounters deprecations. Because every minor point release of Drupal is going to add deprecations, and because in general the deprecation changes aren't backported to other supported versions of core, we're ALWAYS going to have failing tests. Which makes it difficult to notice and fix new failures. For example, some of those failures are things deprecated in 9.3, so if we "fix" them for 9.3 then our 9.2 and 9.1 tests will fail.

Regardless, the point is to look at the PHP 8.1 failures, subtract the branch failures, and see if this patch fixed everything.

I triggered PHP 8.1 tests for this module without this patch (see https://www.drupal.org/pift-ci-job/2237552) and there are 19 failures - 14 are the normal ones, 4 are the count() error fixed by this patch, and 1 is because of Exception: Deprecated function: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated Drupal\Component\Utility\Html::escape() which is also a PHP 8.1 problem but seems to be a core problem, not a problem with Entity API.

Re #3, it seems from the tests results that this patch DOESN'T break the module under PHP 7.

Because this patch DOES fix the count() failures and doesn't break the tests for other versions of PHP, I'm marking this as RTBC.

tr’s picture

I re-opened the issue which introduced drupalci.yml (which is the reason for the branch fails). See #3101368: Let tests fail on deprecation notices.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new565 bytes

Here's a patch that:

alexpott’s picture

StatusFileSize
new2.06 KB

That was not the patch I meant to uplaod here... here it is.

tr’s picture

StatusFileSize
new1.51 KB

The drupalci.yml was removed in #3101368: Let tests fail on deprecation notices

Here's a re-roll of #9 without the changes to drupalci.yml.

  • TR committed 1d24653 on 8.x-1.x authored by alexpott
    Issue #3249372 by mrweiner, alexpott, TR, AardWolf: PHP 8.1:  Deprecated...
tr’s picture

Status: Needs review » Fixed

Committed #10. Tests now run green and Entity API now works with PHP 8.1.

Status: Fixed » Closed (fixed)

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

chi’s picture

Would be nice to have a release with this fix.

vikramy’s picture

+1. A release would be good.