MergeWikiLibDirs
Questions answered by this recipe
How can I move all my pages from the standard PageStore to another one such asDescription
Copy pages from the standard PageStore to a new PageStore such as SQLite.
Notes
This "recipe" does not really deserve the name -- it is currently some theoretical musings. As soon as someone puts together something that works they should definitely scrap what I've got here and take over as maintainer. Meanwhile, these thoughts may help someone?
(I am using the name from Petko's SQLite referenced (but nonexistent) page in hopes that he will put his real script here.)
Glancing through SQLite it appears that Petko has put together an experimental script to import all pages into the DB. However, the referenced page (MergeWikiLibDirs - this current page) no longer exists. I would suggest asking Petko since he's already done the development work on it...
Theoretically (largely glossing over PHP timeouts and some other frustrating issues) something like this might work:
set_time_limit(1800); // allow us 30 minutes if no other timeouts intervene $pl = ListPages(); // you may have to limit this to a group at a time or something for timeout issues foreach ($pl as $pn) { $page = ReadPage($pn); WritePage($pn, $page); }
You could also get a lot fancier, keeping track of the standard PageStore and the SQLite PageStore $Dir and then doing something like this to work around the timeouts:
set_time_limit(900); // allow 15 minutes if no other timeouts intervene - does not work on some platforms $sql = new PageStoreSQLite($WorkDir.'/pmwiki.sqlite.db', 1); $plist_std = ListPages(); $plist_sql = $sql->ls(NULL); $deadline = ini_get('max_execution_time') - 5 + time(); // other timeouts are ignored in this theoretical code... $plist = array_diff($plist_std, $plist_sql); foreach ($plist as $pn) { if ($deadline > time()) break; $page = ReadPage($pn); WritePage($pn, $page); }
The code above could be called multiple time since each time it picks up where it left off...
These thoughts are purely theoretical and code is composed on the fly with no testing... Do *not* mess with live data using this code -- significant work is required in a development environment before live data is actually imported (and then only after a careful backup, obviously!)
Release notes
- 2010-02-07 Purely theoretical thoughts with some code suggestions
See also
Contributors
Comments
See discussion at MergeWikiLibDirs-Talk?
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.