On the URL /node/3/revisions/view/9/10/split_fields looking at a node with an image field I get the error:

The website encountered an unexpected error. Please try again later.
Error: Call to a member function getComponent() on null in Drupal\diff\Plugin\diff\Field\ImageFieldBuilder->build() (line 77 of modules/contrib/diff/src/Plugin/diff/Field/ImageFieldBuilder.php).
Drupal\diff\Plugin\diff\Field\ImageFieldBuilder->build(Object) (Line: 94)
Drupal\diff\DiffEntityParser->parseEntity(Object) (Line: 87)
Drupal\diff\DiffEntityParser->parseEntity(Object) (Line: 97)
Drupal\diff\DiffEntityComparison->compareRevisions(Object, Object) (Line: 115)
Drupal\diff\Plugin\diff\Layout\SplitFieldsDiffLayout->build(Object, Object, Object) (Line: 167)
Drupal\diff\Controller\PluginRevisionController->compareEntityRevisions(Object, Object, Object, 'split_fields') (Line: 49)
Drupal\diff\Controller\NodeRevisionController->compareNodeRevisions(Object, Object, Object, 'split_fields')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

The attached patch fixes the error.

Issue fork diff-2926346

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

dahousecat created an issue. See original summary.

johnchque’s picture

Status: Active » Needs review

Let's trigger testbot. :)

Status: Needs review » Needs work
acbramley’s picture

Status: Needs work » Postponed (maintainer needs more info)

Would be good to understand how a site gets into this state? As far as I know all bundles should have a default display.

dahousecat’s picture

It's a good question - but I am not sure in this instance.

But it's clearly something that can happen.

Any call to entity storage load can either return an EntityInterface or null, and any calls to this method should be able to handle either scenario without causing the whole site to run into a fatal error.

This is just good defensive programming.

acbramley’s picture

Version: 8.x-1.x-dev » 2.x-dev
Status: Postponed (maintainer needs more info) » Active

Of course, I was just trying to understand if this is something many people would encounter.

acbramley’s picture

  • acbramley committed f5421e77 on 2.x
    Issue #2926346 by acbramley, dahousecat: Call to a member function...
acbramley’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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