Skip to content

Commit

Permalink
Prevent infinite loop when pages have been moved in a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
michitux committed Dec 30, 2012
1 parent c6239d0 commit b4ce499
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function rewrite_content($text, $id, $moves) {
while($changed) {
$changed = false;
foreach($tmp_moves as $old => $new) {
if(isset($moves[$new]) && $moves[$new] != $new) {
if($old != $new && isset($moves[$new]) && $moves[$new] != $new) {
$tmp_moves[$old] = $moves[$new];
$changed = true;
}
Expand All @@ -325,7 +325,8 @@ function rewrite_content($text, $id, $moves) {

// manual merge, we can't use array_merge here as ids can be numeric
foreach($tmp_moves as $old => $new) {
$moves[$old] = $new;
if ($old == $new) unset($moves[$old]);
else $moves[$old] = $new;
}

$handlers = array();
Expand Down

0 comments on commit b4ce499

Please sign in to comment.