Problem/Motivation
In the common.inc a recent change made in https://www.drupal.org/node/2756297 causes errors.
There used to be a scalar check but now the value of weight could be anything.
This was no problem until the calculation was added.
Steps to reproduce
Set the weight too for example an array [0, 0] and notice that we get an error.
Error: Unsupported operand types in element_children()
Proposed resolution
Add the scalar check to the weight value.
Patch is added.
We accidentally came across the issue when updating to the latest security update 7.82.