- # Load saved form state and return to edit page.
- my $postrename=CGI->new($session->param("postrename"));
+ # Load saved form state and return to edit page, using stored old
+ # cgi state. Or, if the rename was not started on the edit page,
+ # return to the renamed page.
+ my $postrename=$session->param("postrename");
+ if (! defined $postrename) {
+ IkiWiki::redirect($cgi, urlto(defined $dest ? $dest : $src));
+ exit;
+ }
+ my $oldcgi=CGI->new($postrename);