Loading core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php +1 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter */ protected function getWeight(EntityInterface $entity): int|float { /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */ return $entity->get($this->weightKey); return $entity->get($this->weightKey) ?: 0; } /** Loading core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php +10 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,16 @@ public function testDraggableList() { $this->drupalGet('admin/people/roles'); $this->assertSession()->responseContains('<td>' . Html::escape($role_name)); // Make sure that NULL weights do not break the list builder. Use the // configuration API so that the value does not get type-casted according to // the configuration schema. \Drupal::configFactory() ->getEditable('user.role.role_0') ->set('weight', NULL) ->save(TRUE); $this->drupalGet('admin/people/roles'); $this->assertSession()->statusCodeEquals(200); } } Loading
core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php +1 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter */ protected function getWeight(EntityInterface $entity): int|float { /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */ return $entity->get($this->weightKey); return $entity->get($this->weightKey) ?: 0; } /** Loading
core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php +10 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,16 @@ public function testDraggableList() { $this->drupalGet('admin/people/roles'); $this->assertSession()->responseContains('<td>' . Html::escape($role_name)); // Make sure that NULL weights do not break the list builder. Use the // configuration API so that the value does not get type-casted according to // the configuration schema. \Drupal::configFactory() ->getEditable('user.role.role_0') ->set('weight', NULL) ->save(TRUE); $this->drupalGet('admin/people/roles'); $this->assertSession()->statusCodeEquals(200); } }