Problem/Motivation

We "randomly" encounter the following error:
Error: Call to undefined method ...::getEntity() in gin_everywhere_form_alter() (line 77 of modules/contrib/gin_everywhere/gin_everywhere.module).

The class on which ::getEntity() is called varies, it seems like it's module that extend forms in a generic way.

Steps to reproduce

Last encountered we dealing with ai_chatbot.
I'm not entirely sure what the required steps are to reliably trigger the error.

Proposed resolution

More precise check if the form is actually an instance of \Drupal\Core\Entity\EntityForm which has the ::getEntity() method.

Remaining tasks

  1. ✓ Provide fix
  2. Review

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

das-peter created an issue. See original summary.

das-peter’s picture

Assigned: das-peter » Unassigned
Issue summary: View changes
Status: Needs work » Needs review

Created MR with extended condition before attempting to call ::getEntity()

hydra’s picture

Hey Peter! Really long time no see! Yeah you are right. The form decorator module decorates all forms this might cause that issue.

das-peter’s picture

Maybe we should check for EntityFormInterface instead of EntityForm?

Absolutely correct! Adjusted.

Hey Peter! Really long time no see! Yeah you are right.

Hey Pascal! Indeed, looong time - nice to see ya! :) Didn't have proper drupal projects for a while - but right now getting back in the game.

  • hydra committed 7a3bf426 on 1.x authored by das-peter
    Issue #3482743 by das-peter: Call to undefined method ...::getEntity()
    
hydra’s picture

Status: Needs review » Fixed

Well, welcome back on board :)

das-peter’s picture

Well, welcome back on board :)

Thanks! And thank you for being so responsive :)

hydra’s picture

Np, I will checkout the other issue soon and make a release with the fixes.

kopeboy’s picture

I'm getting a warning by phpcs: Undefined method 'getEntity' (with and without the patch).

Status: Fixed » Closed (fixed)

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