You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix PHP Warning: Undefined property $value in extract()
== What ==
When a Less input file passes a list node to extract(), we access
the internal array value and use that to access the given index.
When a Less input file passes something else to extract(), the value
should be treated as an array containing that 1 node (which means index
1 is the given node, and any other index returns null). This last
part was not working correctly in our implementation.
== Before ==
```
$ bin/lessc test/Fixtures/less.php/less/T391735-extract-non-array.less
PHP Warning: Undefined property: Less_Tree_Call::$value in lib/Less/Functions.php
PHP Warning: Undefined property: Less_Tree_DetachedRuleset::$value in lib/Less/Functions.php
```
A bare slash can also cause the error (as reported at T391735), although
only with `--math=parens-division`, because otherwise the slash operation
is already compiled away before the function call is compiled. Note that
"test/Fixtures/less.php" is registered in test/fixtures.php with math=always.
```
@x: 20px;
.foo-one {
.foo(@x / 1px);
}
.foo(@value: false) when not (@value = false)
and not (extract(@value, 1) = false)
and not (extract(@value, 2) = false)
and not (extract(@value, 3) = false)
and not (extract(@value, 4) = false)
and not (extract(@value, 5) = false) {
foo: @value;
}
```
```
$ bin/less --math=parens-division tmp.less
PHP Warning: Undefined property: Less_Tree_Operation::$value in lib/Less/Functions.php
```
== How ==
We already did the right thing in Functions::length(), where we list
the two Less_Tree classes that represent list nodes and have internal
array values.
Update our implementation to match Less.js 3.13, which moved this
logic to getItemsFromNode() and re-uses it in Functions::extract().
Bug: T391735
Change-Id: Id64ff9f13039571caf475d2e4085d2ef06654508
0 commit comments