Problem/Motivation

If you have e.g. address module 2.x installed and update diff diff module to new ^2.0 stable version, the following error occures:

Declaration of Drupal\address\Plugin\diff\Field\AddressFieldBuilder::build(Drupal\Core\Field\FieldItemListInterface $field_items) must be compatible with Drupal\diff\Plugin\diff\Field\CoreFieldBuilder::build(Drupal\Core\Field\FieldItemListInterface $field_items): array in /var/www/html/docroot/modules/contrib/address/src/Plugin/diff/Field/AddressFieldBuilder.php on line 24

Steps to reproduce

  • Set up a site with address module (^2.0) and diff (^2.0)
  • Create content revisions and try to compare them with the diff module -> fatal error happens on diff page

Proposed resolution

  • Either fix the error (recommended, but keep compatibility with diff ^1.0 in mind) or adjust the version constraint or introduce new conflict entry for diff module in composer.json to ignore ^2.0 versions until the issue is fixed (not recommended, because it only moves the problem to the future)

Remaining tasks

  • Create issue fork and MR to fix this issue

User interface changes

n/a

API changes

n/a

Data model changes

n/a

CommentFileSizeAuthor
#7 address-3589015-7.patch561 bytesbala_28

Issue fork address-3589015

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

hctom created an issue. See original summary.

hctom’s picture

Issue summary: View changes
hctom’s picture

Issue summary: View changes

Just fixing typos and formatting in issue body ;)

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

gurkawal’s picture

I replicated this issue on Drupal 11 with Address 2.x and Diff 2.x.

The issue occurs because Diff 2.x updated a method to require an array return type, while the Address module was still using the older method definition. This causes a fatal error on the content revision diff page.

The fix is to add the missing : array return type to AddressFieldBuilder::build() so the method signatures match correctly.

After reviewing the issue and codebase, I found that this fix is already present in the current 2.0.x-dev branch, so there are no additional changes left for a new MR.

However, the latest stable release (2.0.4) does not yet include this fix, so a new stable release from the updated 2.0.x branch is needed.

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

bala_28’s picture

StatusFileSize
new561 bytes

Adding patch for 2.0.4 version

joachim’s picture

Status: Active » Needs work
Issue tags: +Novice

Patch looks good but someone needs to make an MR from it.

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

idebr changed the visibility of the branch 3589015-incompatibility-with-diff to hidden.

idebr’s picture

joegl’s picture

It was fixed a few years ago but no release has been made with the fix.

brandonlira’s picture

Confirmed. The change from the patch is already present in 2.0.x-dev via #3460590, but it is not included in the latest stable release, 2.0.4.

I think this can be handled by publishing a new 2.0.x release rather than creating another MR.

ifrik’s picture

I have the same problem with Address 2.0.4 and Diff 2.0.1 as well as with Diff 2.1.1

After applying the patch #7, I get this error

InvalidArgumentException: Invalid $mode 3 specified in Drupal\Component\Diff\DiffOpOutputBuilder->hunkOp() (line 127 of core/lib/Drupal/Component/Diff/DiffOpOutputBuilder.php).

a8w4’s picture

This error also blocks the fields config page of the Diff module:

Fatal error: Declaration of Drupal\address\Plugin\diff\Field\AddressFieldBuilder::build(Drupal\Core\Field\FieldItemListInterface $field_items) must be compatible with Drupal\diff\Plugin\diff\Field\CoreFieldBuilder::build(Drupal\Core\Field\FieldItemListInterface $field_items): array in /var/www/html/drupal/web/modules/contrib/address/src/Plugin/diff/Field/AddressFieldBuilder.php on line 24

Steps to reproduce

  • have address (2.0.4) and diff (2.1.1) module installed
  • goto /admin/config/content/diff/fields



This is a major showstopper for the diff module - please fix soon!

tvalimaa’s picture

I get this on Drupal 11.4 / PHP 8.4 with address 2.0.4 and diff 2.1.1. The revision comparison page on nodes with address fields was returning a 500 error. Applied the patch from comment #7 and it resolved the issue immediately.

Address: 2.0.4
Diff: 2.1.1
Drupal: 11.4
PHP: 8.4

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

benstallings’s picture

Status: Needs work » Needs review

  • dww committed add0ac16 on 2.1.x
    task: #3589015 Add test for diff plugin and compatibility with diff ^2.0...

  • dww committed 3c4c5e6d on 2.0.x
    task: #3589015 Add test for diff plugin and compatibility with diff ^2.0...
dww’s picture

Status: Needs review » Fixed

Thanks for the test. Our GitLab CI test-only job didn't make it easy to verify, but I confirmed locally that the test fails with address 2.0.4 and diff 2.*. Committed and pushed to 2.1.x and 2.0.x. The 2.x branch is sort of abandoned at this point. 😬

I only mentioned benstallings and myself in the commit message, since what I committed had nothing to do with the earlier (mostly duplicate) effort in this issue. However, I saved credit for other folks on the contribution credit, since you did try to help in other ways.

Thanks again,
-Derek

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.

dww’s picture

Title: Incompatibility with diff ^2.0 » Add test for compatibility with diff ^2.0
Category: Bug report » Task

Status: Fixed » Closed (fixed)

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