Issue Bug Closed

#91547Unique slug building fallback is broken

filigivuji filigivuji 05/31/20, 01:11 updated 09/29/20, 15:07

Description

SlugHelper.php contains three occasions of a loop like this:

        $counter = 0;
        while (!$this->isUniqueInSite( /* ... */
        ) && $counter++ < 100
        ) {
            /* ... */
        }
        if ($counter === 100) {
            /* ... */
        }

This loop is broken because the comparison uses post-increment, and in case no valid slug with a counter suffix is found, $counter will be 101, not 100.
Note that I didn’t bother to try to reproduce this. Unless I’m overlooking something, I suppose this case has never been tested to begin with.

Affects master, 10.4 and 9.5.

Reviews 2