Try to access $parentField . '_weight' instead of $parentField . '__weight' in loadSiblingEntityWeights()

Issue information

From user: megadesk3000

Contribution record

Fork management

When i try to save a child entity with a set weight, the function loadSiblingEntityWeights() generates the following warning:

Warning: array_combine(): Both parameters should have an equal number of elements in Drupal\entity_hierarchy\Plugin\Field\FieldType\EntityReferenceHierarchy->loadSiblingEntityWeights() (line 250 of modules/contrib/entity_hierarchy/src/Plugin/Field/FieldType/EntityReferenceHierarchy.php).
Drupal\entity_hierarchy\Plugin\Field\FieldType\EntityReferenceHierarchy->loadSiblingEntityWeights(Array) (Line: 283)
Drupal\entity_hierarchy\Plugin\Field\FieldType\EntityReferenceHierarchy->getSiblingEntityWeights(Object, Object, Object) (Line: 166)
Drupal\entity_hierarchy\Plugin\Field\FieldType\EntityReferenceHierarchy->postSave(1)
call_user_func_array(Array, Array) (Line: 233)
Drupal\Core\Field\FieldItemList->delegateMethod('postSave', 1) (Line: 198)
Drupal\Core\Field\FieldItemList->postSave(1) (Line: 33)
Drupal\entity_hierarchy\Plugin\Field\FieldType\EntityReferenceHierarchyFieldItemList->postSave(1)
call_user_func_array(Array, Array) (Line: 873)
Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod('postSave', Object, 1) (Line: 905)
Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldPostSave(Object, 1) (Line: 831)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 526)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 720)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 451)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 838)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 394)
Drupal\Core\Entity\EntityBase->save() (Line: 71)
Drupal\sapros_filter\Form\FilterAttributeForm->save(Array, Object)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 590)
Drupal\Core\Form\FormBuilder->processForm('sapros_filter_attribute_edit_form', Array, Object) (Line: 319)
Drupal\Core\Form\FormBuilder->buildForm('sapros_filter_attribute_edit_form', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
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}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
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: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

In my opinion the problem can be fixed by changing $parentField . '_weight' to $parentField . '__weight'

Edited by drupalbot
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information