contao/issues — Issue #189: error-prone method combiner() in DataContainer
Author: importer
Created: 2011-11-24 12:23:20+00:00
State: open
Labels: backend, Defect

The method container uses a form of foreach-loop that will not work in all conditions. It currenty works in 99,9% or more installations, but may (or may not) stop to work as the php development goes on. Especially when php 6 comes out, there could be broken code as a result.

The foreach loops over an array, that is reset in the loop. This can in rare conditions lead to an infinite loop. It's not just theoretical, I have a running VM with Debian Etch and standard php installtion which cannot run TL because of this error.

```
protected function combiner($names)
{
$return = array(_);

for ($i=0; $i$v)
{
$buffer[] = ($k%2 == 0) ? $v : $v.$names[$i];
$buffer[] = ($k%2 == 0) ? $v.$names[$i] : $v;
$return = $buffer;
}
}

return $return;
}
```

Should be:

```
protected function combiner($names)
{
$return = array(_);

for ($i=0; $i$v)
{
$buffer[] = ($k%2 == 0) ? $v : $v.$names[$i];
$buffer[] = ($k%2 == 0) ? $v.$names[$i] : $v;
}
$return = $buffer;
}

return $return;
}
```

--- _Originally created by markus.milkereit on October 14th, 2008, at 06:25pm (ID 189)_