Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292508

AJAX save of an Article node results in an error related to the image field

$
0
0

I've tried to gather as much info about this issue as possible. Sadly I'm not able to resolve it, although I felt I was close at times. Let's start with the pathology.

Steps to reproduce.

  1. Install the lastest 8.x
  2. Enable the language module. This error does not occur if the language module is disabled.
  3. Apply the patch in this issue (unless it has already been committed): #1960612: jQuery UI 1.10 update broke Create.js, and thus in-place editing
  4. Create an Article node with a title and body, but not image in the image field.
  5. Go to the node page (node/1) and select "Quick edit" from the contextual links.
  6. Change the body field test and click Save.
  7. You should see an AJAX error like this:

Screenshot of the AJAX error.

The text of the error

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /edit/form/node/2/body/und/full
StatusText: OK
ResponseText: Recoverable fatal error: Argument 1 passed to Drupal\file\FileUsage\DatabaseFileUsageBackend::add() must be an instance of Drupal\file\Plugin\Core\Entity\File, boolean given, called in /Users/jbeach/code/drupal/core/d8/core/modules/file/file.field.inc on line 267 and defined in Drupal\file\FileUsage\DatabaseFileUsageBackend->add() (line 51 of /Users/jbeach/code/drupal/core/d8/core/modules/file/lib/Drupal/file/FileUsage/DatabaseFileUsageBackend.php).

I think this error begins with a bad value assigned to the image field's language property. It surfaces like this:

$entity->field_image['und'] = array(0 => NULL);

I don't know where this assignment happens, that's been the focus of my debugging efforts. I assume it happens somewhere in the field composition stages. Here is what the error looks like in _field_invoke() in field.attach.inc.

Screenshot showing the $items of the field_image is set to a non-empty array that contains one index whose value is NULL.

The $items variable on line 411 is set to array('0' => NULL) which causes two bad things to happen:

  1. empty($items) returns FALSE.
  2. for loops on the $items variable run through one iteration on a value that is NULL.

These two behaviors account for the downstream errors. The first we see in the logs is a call to array_flip on an array that contains a non-string or non-number value because the value is NULL.

Screenshot of the FileStorageControll load method. array_flip is called on an array with one property at the zero index. The value of this item is NULL.

I've looked in the language module but don't see where where a NULL value is pushed into an array e.g. $someArray[] = NULL or something similar.

AttachmentSizeStatusTest resultOperations
Screenshot_4_6_13_3_18_PM.png61.4 KBIgnored: Check issue status.NoneNone
Screenshot_4_6_13_2_04_PM.png236.71 KBIgnored: Check issue status.NoneNone
Screenshot_4_6_13_1_54_PM.png159.11 KBIgnored: Check issue status.NoneNone

Viewing all articles
Browse latest Browse all 292508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>