From: <var...@us...> - 2021-09-16 15:23:42
|
Revision: 10555 http://sourceforge.net/p/phpwiki/code/10555 Author: vargenau Date: 2021-09-16 15:23:40 +0000 (Thu, 16 Sep 2021) Log Message: ----------- Move function delete_page from lib/WikiDB/backend.php to lib/WikiDB/backend/PearDB.php; all backends implement it Modified Paths: -------------- trunk/lib/WikiDB/backend/PearDB.php trunk/lib/WikiDB/backend.php Modified: trunk/lib/WikiDB/backend/PearDB.php =================================================================== --- trunk/lib/WikiDB/backend/PearDB.php 2021-09-14 16:59:19 UTC (rev 10554) +++ trunk/lib/WikiDB/backend/PearDB.php 2021-09-16 15:23:40 UTC (rev 10555) @@ -939,6 +939,45 @@ return $id; } + /** + * Delete page from the database with backup possibility. + * This should remove all links (from the named page) from + * the link database. + * + * @param string $pagename Page name. + * i.e save_page('') and DELETE nonempty id + * Can be undone and is seen in RecentChanges. + */ + + function delete_page($pagename) + { + /** + * @var WikiRequest $request + */ + global $request; + + $mtime = time(); + $user =& $request->_user; + $vdata = array('author' => $user->getId(), + 'author_id' => $user->getAuthenticatedId(), + 'mtime' => $mtime); + + $this->lock(); // critical section: + $version = $this->get_latest_version($pagename); + $this->set_versiondata($pagename, $version + 1, $vdata); + $this->set_links($pagename, array()); // links are purged. + // SQL needs to invalidate the non_empty id + if (!WIKIDB_NOCACHE_MARKUP) { + // need the hits, perms and LOCKED, otherwise you can reset the perm + // by action=remove and re-create it with default perms + $pagedata = $this->get_pagedata($pagename); + unset($pagedata['_cached_html']); + $this->update_pagedata($pagename, $pagedata); + } + $this->unlock(); + } + + function _update_recent_table($pageid = false) { $dbh = &$this->_dbh; Modified: trunk/lib/WikiDB/backend.php =================================================================== --- trunk/lib/WikiDB/backend.php 2021-09-14 16:59:19 UTC (rev 10554) +++ trunk/lib/WikiDB/backend.php 2021-09-16 15:23:40 UTC (rev 10555) @@ -170,7 +170,6 @@ * @param string $pagename Current page name * @param string $to Future page name */ - abstract function rename_page($pagename, $to); /** @@ -182,34 +181,8 @@ * i.e save_page('') and DELETE nonempty id * Can be undone and is seen in RecentChanges. */ - function delete_page($pagename) - { - /** - * @var WikiRequest $request - */ - global $request; + abstract function delete_page($pagename); - $mtime = time(); - $user =& $request->_user; - $vdata = array('author' => $user->getId(), - 'author_id' => $user->getAuthenticatedId(), - 'mtime' => $mtime); - - $this->lock(); // critical section: - $version = $this->get_latest_version($pagename); - $this->set_versiondata($pagename, $version + 1, $vdata); - $this->set_links($pagename, array()); // links are purged. - // SQL needs to invalidate the non_empty id - if (!WIKIDB_NOCACHE_MARKUP) { - // need the hits, perms and LOCKED, otherwise you can reset the perm - // by action=remove and re-create it with default perms - $pagedata = $this->get_pagedata($pagename); - unset($pagedata['_cached_html']); - $this->update_pagedata($pagename, $pagedata); - } - $this->unlock(); - } - /** * Delete page (and all its revisions) from the database. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |