Problem/Motivation
Running into this error while placing a block to a page using Layout Builder
TypeError: krsort(): Argument #1 ($array) must be of type array, null given in krsort()
Steps to reproduce
- Use a Drupal node that has Layout Builder enabled
- Go to the Layout Builder configure page
- Try to place a block
- The AJAX response gives out an error reported above
Proposed resolution
- Use the null coalescing operator to replace NULL with an empty array so that PHP 8.1 does not report a Deprecation error
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3315720-fix-krsort-deprecation-3.patch | 630 bytes | gauravjeet |
Comments
Comment #2
gauravjeet commentedComment #3
gauravjeet commentedAttaching a patch for the fix. This resolves the PHP 8.1 deprecation notice and allows AJAX request to complete successfully.
Comment #5
podaroktnx
Comment #7
geek-merlinBulk reopen.
Comment #8
dcam commentedThis needs better steps to reproduce the problem, specifically in regard to the configuration of the entities involved. Does the node have the IEF field or the block? Are you placing the block on the node type's default layout or customizing the layout of a single node? Does the IEF field (whatever entity it's attached to) need to have entities referenced or be empty? I've tried every combination that I can think of and can't reproduce the problem. I'll admit that the code looks like it has this issue. But if it can't be reproduced then that's a problem because if it's a bug then this also needs tests.
Comment #9
geek-merlinOhoh, i remember well when i coded that. Context:
No guarantee that there are widget states at this point. So it's as simple as this one with no regression risk:
Comment #10
geek-merlinAh, i forgot the
which makes #9 impossible and mandates the extra line from #3.
Comment #12
geek-merlin