[pmwiki-users] WritePage question

Patrick R. Michaud pmichaud at pobox.com
Sat Sep 16 15:40:54 CDT 2006


On Sat, Sep 16, 2006 at 06:38:57PM +0200, Tom Lederer wrote:
> Hi all,
> 
> i want to write a script which allows non logged in users to edit  
> something.
> Of the security issue i am well aware :)
> 
> However i lose the history. [...]

WritePage() is a low-level function that simply writes whatever 
it's told to write.  WritePage() doesn't create or maintain
page histories, update RecentChanges, etc.

To update a page with a page history, one currently has to
call PostPage() (which requires a couple of extra functions).

It's also possible to call HandleEdit() directly, which
(with the correct parameters set) can perform a post just as
if it were coming from a browser.

However, it's very likely that in the next release of PmWiki
there will be a generic "update page" function that will
allow scripts to update pages as if they were coming from
a browser, including updating the page history, updating
RecentChanges, sending out notification emails, etc.


That said, here's a couple of comments:

> Here is what i do (comment what i want it to do):
> 
> Lock(2);					# lock page
> $page = ReadPage($pagename, READPAGE_CURRENT);  # read page into  

The READPAGE_CURRENT option to ReadPage means to only read the
current version of the page without its history, and this
is where you're losing the history.  If you change this line
to simply be

    $page = ReadPage($pagename);

then the history will still be in the file.  However, since
you're next changing the text of the page (but not making a new
history entry, it won't be possible to get back to previous
versions of the page.

Hope this helps,

Pm




More information about the pmwiki-users mailing list