Commit a2d8174c authored by Dries's avatar Dries
Browse files

- Patch #39875 by chx: form_sort is broken with PHP5.

parent 77f55aa7
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* Check if the key is a property. * Check if the key is a property.
*/ */
function element_property($key) { function element_property($key) {
return $key{0} == '#'; return $key[0] == '#';
} }
function element_properties($element) { function element_properties($element) {
...@@ -30,7 +30,7 @@ function element_properties($element) { ...@@ -30,7 +30,7 @@ function element_properties($element) {
* Check if the key is a child. * Check if the key is a child.
*/ */
function element_child($key) { function element_child($key) {
return $key{0} != '#'; return $key[0] != '#';
} }
function element_children($element) { function element_children($element) {
...@@ -358,10 +358,9 @@ function form_render(&$elements) { ...@@ -358,10 +358,9 @@ function form_render(&$elements) {
* Function used by uasort in form render to sort form via weight. * Function used by uasort in form render to sort form via weight.
*/ */
function _form_sort($a, $b) { function _form_sort($a, $b) {
if ($a['#weight'] == $b['#weight']) { $a_weight = (is_array($a) && isset($a['#weight'])) ? $a['#weight'] : 0;
return 0; $b_weight = (is_array($b) && isset($b['#weight'])) ? $b['#weight'] : 0;
} return $a_weight - $b_weight;
return ($a['#weight'] < $b['#weight']) ? -1 : 1;
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment