I asked a while ago:
> I currently use gdbm as my phpwiki backend, but for various
> reasons I want
> to change that to a mySQL backend. So what I thought of doing
> was taking a
> ZipDump of the entire wiki, changing the backend (setting up
> the database
> schema, changing the entry script, blah blah) and use the
> loadfile action on
> the new (empty) wiki to restore the wiki to its original state.
>
> Currently this just doesn't work. Well, not as I expected, at
> any rate. The
> first revision is saved as version one, and subsequent
> revisions have to be
> merged by hand.
Well, I hacked something together by chopping in lib/loadsave.php and
lib/WikIDB.php.
In summary, I commented out most of SavePage (all the bits with checking to
see if we want to merge or overwrite pages) and just save the revisions as
they come out the RFC822 files. Then in WikiWD.php I cut out the sanity
checking of revision numbers and overwrite existing revisions. This is, of
course, directly counter to the philosophy that old revisions are read only,
but this was a temporary hack and I wanted to exactly restore a wiki.
In detail, here are the diffs: (foo.restore is my special hacked version of
foo.php, of course)
-bash-2.05b$ diff loadsave.php loadsave.php.restore
376a377,380
> echo $pageinfo['pagename'] . ', ' . $pageinfo['version'];
> $page = $dbi->getPage($pagename);
> $page->save($content, $pageinfo['version'], $versiondata);
> /*
483a488
> */
-bash-2.05b$ diff WikiDB.php WikiDB.php.restore
21a22
> define('WIKIDB_RESTORE', 1);
615,621c616,628
< $latestversion = $backend->get_latest_version($pagename);
< $newversion = $latestversion + 1;
< assert($newversion >= 1);
<
< if ($version != WIKIDB_FORCE_CREATE && $version != $newversion) {
< $backend->unlock();
< return false;
---
> if (WIKIDB_RESTORE) {
> $latestversion = 0;
> $newversion = $version;
> } else {
>
> $latestversion = $backend->get_latest_version($pagename);
> $newversion = $latestversion + 1;
> assert($newversion >= 1);
>
> if ($version != WIKIDB_FORCE_CREATE && $version !=
$newversion) {
> $backend->unlock();
> return false;
> }
Then for each wiki I first created an IdontExist page, made its content
"<?plugin WikiForm action=loadfile?>", logged in as admin & hit the button.
It seemed to work OK, although I'm still checking out the nitty gritties &
corners of my wikis.
frank
|