[pmwiki-users] Keeping history when updating pages via php

Eemeli Aro eemeli at gmail.com
Sun Aug 1 12:47:20 CDT 2010

On 1 August 2010 20:42, Wordit Ltd <wordituk at googlemail.com> wrote:
> How do you keep the full page history when using UpdatePage($pn, $old,
> $page) from PHP?
> I tried the following, reading the current page values into $old. But
> there are no diffs added to the page source in wiki.d (and rev=1).
> It's just overwriting, as though the page had not existed. Do I have
> to call another function to get history added?
> $page['text'] = 'the new text';
> $pn = 'MyGroup.MyPage';
> $old = ReadPage($pn);
> UpdatePage($pn, $old, $page);

Change that to:

$pn = 'MyGroup.MyPage';
$page = $old = ReadPage($pn);
$page['text'] = 'the new text';
UpdatePage($pn, $old, $page);

$page replaces $old, and the way you had it you weren't including
anything but $page['text']; by first reading the page and then
adding/modifying the fields you use you'll keep the history as well.


More information about the pmwiki-users mailing list