--- dokuwiki-plugin-pagemove-20110811/admin.php~ 2012-06-12 23:48:17.000000000 +0300 +++ dokuwiki-plugin-pagemove-20110811/admin.php 2012-06-12 23:50:28.916910665 +0300 @@ -370,10 +370,10 @@ // Set things up to display the new page. io_saveFile($conf['cachedir'].'/purgefile', time()); - $ID = $opts['new_id']; - $ACT = 'show'; - $INFO = pageinfo(); - $this->show_form = false; + + // redirect to page display + Header("Location: ".wl($opts['new_id'])); + exit; } else { $this->errors[] = $this->lang['pm_fatal']; @@ -618,14 +618,28 @@ saveWikiText($ID, '', $this->lang['pm_delete'] ); } + // replace our old id with new one as we already renamed the page but + // there might be backlinks (links to self in this case). + $opts['id'] = cleanID($opts['ns'].':'.$opts['name']); + $selfmod = isset($backlinks[$opts['id']]); + if ($selfmod) { + $backlinks[$opts['new_id']] = $backlinks[$opts['id']]; + unset($backlinks[$opts['id']]); + } + // Loop through backlinks foreach($backlinksById as $backlinkingId => $backlinks) { - $this->_pm_updatebacklinks($backlinkingId, $backlinks, $opts, $brackets); + $this->_pm_updatebacklinks($backlinkingId, $backlinks, $opts); } // Move the old revisions $this->_pm_movemeta('olddir', '/^'.$opts['name'].'\.[0-9]{10}\.txt(\.gz)?$/', $opts); + // remove cache. again if we ourselves were modified (due backlinks) + if ($selfmod) { + $cache = new cache_instructions($opts['new_id'], wikiFN($opts['new_id'])); + $cache->removeCache(); + } } @@ -637,7 +637,7 @@ * * @author Gary Owen */ - function _pm_updatebacklinks($backlinkingId, $links, $opts, &$brackets) { + function _pm_updatebacklinks($backlinkingId, $links, $opts) { global $ID; // Get namespace of document we are editing @@ -730,8 +730,8 @@ // Make the changes $this->_pm_updatelinks($text, $oid); - // Save backlink and release lock - saveWikiText($backlinkingId, $text, sprintf($this->lang['pm_linkchange'], $ID, $opts['new_id'])); + // Save backlink and release lock. call the edit minor to avoid mail flood on marge backlinks changes + saveWikiText($backlinkingId, $text, sprintf($this->lang['pm_linkchange'], $ID, $opts['new_id']), 1); unlock($backlinkingId); }