Getting the following error after upgrading the lastest version of Paragraphs 8.x dev:
Notice: Undefined offset: 1 in paragraphs_preprocess_field_multiple_value_form() (line 284 of modules/paragraphs/paragraphs.module).
paragraphs_preprocess_field_multiple_value_form(Array, 'field_multiple_value_form', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('field_multiple_value_form', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
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 page is a node edit page with a paragraph attachment. If I remove the sole attached paragraph the error goes away. If I add it back again (with no values) the error returns.
If I roll back to the previous dev version of paragraphs (8.x-1.1+48-dev), the error goes away.
Looks like new code. This function doesn't exist in the previous version of paragraphs:
function paragraphs_preprocess_field_multiple_value_form(&$variables) {
if (count($variables['element']['#field_parents']) === 0 && isset($variables['table']['#rows'])) {
// Find header_action and move to header.
// @see template_preprocess_field_multiple_value_form()
foreach ($variables['table']['#rows'] as $i => $row) {
if (isset($variables['table']['#rows'][$i]['data'][1]['data']['#attributes']['class'])) {
if ($variables['table']['#rows'][$i]['data'][1]['data']['#attributes']['class'][1] === 'paragraphs-header-actions') {
$variables['table']['#header'][0]['data'] = [
'title' => $variables['table']['#header'][0]['data'],
'button' => $variables['table']['#rows'][$i]['data'][1],
];
unset($variables['table']['#rows'][$i]);
break;
}
}
}
}
}
Digging into this with a bit of debug/kint, it looks like $variables['table']['#rows'][$i]['data'][1]['data']['#attributes']['class'] is an empty array for me. So it passes isset($variables['table']['#rows'][$i]['data'][1]['data']['#attributes']['class']), but $variables['table']['#rows'][$i]['data'][1]['data']['#attributes']['class'][1] is undefined.
If I make the logical change:
if (isset($variables['table']['#rows'][$i]['data'][1]['data']['#attributes']['class'])) {
and modify this to:
if (isset($variables['table']['#rows'][$i]['data'][1]['data']['#attributes']['class'][1])) {
The error goes away.
I could submit this as a patch, but I don't know enough about the new function to understand why it's there in the first place.
Comment | File | Size | Author |
---|---|---|---|
#8 | undefined-offset-2895992-8.patch | 909 bytes | _gradient_ |
| |||
#6 | video-bug.png | 55.29 KB | Andrew Gorokhovets |
#6 | undefined-offset-in_paragraphs_preprocess_field_multiple_value_form2895992-6.patch | 869 bytes | Andrew Gorokhovets |
| |||
#6 | debug.png | 670.91 KB | Andrew Gorokhovets |
#3 | undefined-offset-2895992-3.patch | 837 bytes | TrevorBradley |
Comments
Comment #2
johnchqueMakes sense to me to do the change you suggest. Would you provide a patch with that small change so we could see if it breaks any test?
As far as I know, the code was added for having a "Collapse all" button. :)
Comment #3
TrevorBradley CreditAttribution: TrevorBradley commentedOK, see attached patch.
Comment #4
BerdirThanks. I noticed a similar problem in #2825575: Introduce a Drag & Drop Mode and fixed it differently, with an in_array() check.
I'm working hard on finishing that issue, but I can't make a promise when it will be committed as it is one of the most complicated things I've ever worked on. Feel free to take my fix there, verify it fixes the problem for you and post a standalone patch here for this.
Comment #5
TrevorBradley CreditAttribution: TrevorBradley commentedVerified that the patch for #2825575: Introduce a Drag & Drop Mode also fixes this problem.
Comment #6
Andrew Gorokhovets CreditAttribution: Andrew Gorokhovets as a volunteer commentedHi, I updated the patch because it still needed.
Also this error comes with Bricks integration, please take a look the video.
As mention @TrevorBradley the problem is in paragraphs_preprocess_field_multiple_value_form()
So I updated the patch.
Please take a look.
Comment #8
_gradient_ CreditAttribution: _gradient_ as a volunteer and at AnyforSoft commentedThe issue is still actual. Here's the updated patch of @Andrew Gorokhovets for the last module version.
Comment #9
2phaGot this today too on an established site to which I added the paragraphs module (8.x-1.14).
I had not added any paragraphs to the site yet, but when I navigated to a page to add a node (which had a multiple value textfield) I encountered this error.
Patch #8 fixed it.
Comment #10
2pha