fix overeager optimization in Table handler. fixes #4186

This reverts an optimization introduced in
bcaec9f47d

The number of elements in $this->tableCalls may change during the loop,
so they need to be recounted on every step. To protect it from being
"optimized" again, the loop was changed into a while loop.

Ultimately it should be checked if this method could be optimized in
another way.
This commit is contained in:
Andreas Gohr 2024-02-07 09:09:09 +01:00
parent ab86a1cdff
commit 643ea3a6ea
1 changed files with 2 additions and 5 deletions

View File

@ -167,15 +167,12 @@ class Table extends AbstractRewriter
$this->inTableHead = false;
$this->countTableHeadRows = 0;
}
// Look for the colspan elements and increment the colspan on the
// previous non-empty opening cell. Once done, delete all the cells
// that contain colspans
$counter = count($this->tableCalls);
// Look for the colspan elements and increment the colspan on the
// previous non-empty opening cell. Once done, delete all the cells
// that contain colspans
for ($key = 0; $key < $counter; ++$key) {
$key = -1;
while (++$key < count($this->tableCalls)) {
$call = $this->tableCalls[$key];
switch ($call[0]) {