Problem/Motivation

Using Diff version ^2

  • Fatal error: Declaration of Drupal\state_machine\Plugin\diff\Field\StateFieldBuilder::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 /src/Plugin/diff/Field/StateFieldBuilder.php on line 24
  • RendererInterface::renderPlain() is deprecated in favour of ::renderInIsolation()

Steps to reproduce

I went into content revisions and try to Compare selected revisions and that errors appears.

Proposed resolution

  • Add 'array' as the function return type in build
  • Change renderPlain() into renderInIsolation()

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Issue fork diff-3542871

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:

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

saidatom created an issue. See original summary.

saidatom’s picture

Issue summary: View changes
saidatom’s picture

Project: Diff » State Machine
Version: 2.x-dev » 8.x-1.x-dev
saidatom’s picture

Issue summary: View changes

saidatom changed the visibility of the branch 3542871-fatal-error-and to hidden.

saidatom’s picture

Assigned: saidatom » Unassigned
Status: Active » Needs review
huzooka’s picture

Status: Needs review » Needs work
saidatom’s picture

Status: Needs work » Needs review
jsacksick’s picture

Status: Needs review » Needs work

The change isn't valid as is.
The deprecation helper was introduced in D10.1.3, and we currently still support D9. So either we drop support as part of this change, or we do this differently.

Also the return type issue can be fixed separately from the renderInIsolation() calls.

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

tbkot’s picture

Status: Needs work » Needs review

MR is updated to include "conflict" in the composer for the diff module 2+ version. I suggest creating a separate issue and a new branch to disable D9 support, where we can use diff 2+ and update the StateFieldBuilder class to be compatible.

jsacksick’s picture

Status: Needs review » Needs work

I see no problem updating the return type and still support diff v2 from the same branch.
There is no issue with that, specifying the return type isn't going to break the v1 support.

tbkot’s picture

Status: Needs work » Needs review

@jsacksick return type is updated, and composer.json reverted to default.

  • jsacksick committed f360ff6e on 8.x-1.x authored by saidatom
    fix: #3542871 Fatal error and deprecated code: StateFieldBuilder
    
    By:...
jsacksick’s picture

Status: Needs review » 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.

Status: Fixed » Closed (fixed)

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