I have this fatal error on one of my sites when trying to call the core/lib/Drupal/Core/Menu/MenuParentFormSelector.php::parentSelectElement() method with an empty $menu_parent argument.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | 2950729-23.patch | 771 bytes | _utsavsharma |
| #23 | interdiff_d10.txt | 771 bytes | _utsavsharma |
| #14 | 2950729-14.patch | 778 bytes | drugan |
| #11 | 2950729-11.patch | 784 bytes | pagach |
| #2 | 2950729-2.patch | 755 bytes | drugan |
Issue fork drupal-2950729
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:
- 2950729-undefined-offset-1
compare
- 2950729-undefined-offset
changes, plain diff MR !8311
Comments
Comment #2
drugan commentedThis fixed my issue.
Comment #3
drugan commentedComment #4
zerolab commentedThis works wonders. Simple and got rid of the pesky warning.
LGTM!
Comment #5
alexpottThe fix looks solid but the question is how does this happen and can we add test coverage?
In order to commit a bug fix we need an automated to test to prove that we've fixed the bug and ensure that we don't break it again in the future. For more information about writing tests in Drupal 8 see the following links:
I think we can improve this by doing something like
if (strpos($menu_parent, ':') !== FALSE && !isset($options[$menu_parent])) {just to be super sure the explode is going to work.Comment #6
zerolab commentedIn our case, it happened when the node type should not be added to a menu:
This is the configuration:
As you can see parent is empty. Which is what triggers the warning.
Comment #7
drugan commented@alexpott
I've encountered the error while working with some client's site to which I don't have access now. I use my own devel module hack for error reporting and see them automatically like this one:
https://www.drupal.org/files/issues/2018-03-24/field-condition-error1.png
So, now I don't even remember how and where the error appeared.
Again, I am not sure now but what I remember from debugging the case is that somewhere it were output like a bare colon like ":" instead of "PARENT:CHILD". So, your way of testing the variable might not work.
Comment #8
alexpott@drugan the colon check will work fine see https://3v4l.org/MRPHq vs https://3v4l.org/Cb3UV
Comment #10
ljgra commentedI encountered this issue when I installed the module menu_condition, when the menu parent defaults to -None-. The patch fixed it.
Comment #11
pagach commentedEncountered this too. Variable check did not work but colon check did. Here's a patch then.
Comment #12
aleevasComment #13
aleevasComment #14
drugan commentedComment #15
ljgra commentedThanks for the patch!
Comment #22
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Tagging for steps to reproduce. #6 mentions content type that doesn't use a menu, tried replicating on D10 but could not
Was previously tagged for tests that will still need to happen.
Thanks!
Comment #23
_utsavsharma commentedPatch for 10.1.x.
Comment #25
useernamee commentedWe're using patch #11 and it fixes our issue.
Comment #28
kalpanajaiswal commentedCreate an MR with patch #11
MR: https://git.drupalcode.org/project/drupal/-/merge_requests/8311
Comment #29
kalpanajaiswal commentedComment #30
smustgrave commentedHi @kalpanajaiswal FYI turning existing patches to MR isn't credit worthy unless addressing other points which have not been done. So not saving credit.
Steps are still needed.
Issue summary is incomplete
Comment #31
dcam commentedI tried really hard to reproduce this issue and could not. I can see how it could happen, given some set of circumstances that likely involves a contributed module. I even installed the menu_condition module since there's a related issue in its queue about this same problem. I still couldn't make it happen.
If you are experiencing this issue, then please update the issue summary with detailed steps to reproduce the problem beginning with a fresh installation of Drupal Core.
Comment #33
smustgrave commentedSince steps to reproduce haven't been provided or summary updated going to close out. If still a bug in D11 please re-open