[pmwiki-users] using UpdatePage() from cookbook

V.Krishn vkrishn at insteps.net
Sat Jan 9 03:45:49 CST 2010

I managed to extract the necessary code as below, though there are some 

    global $EnablePost, $ChangeSummary, $Now, $IsPagePosted;
    $page = RetrieveAuthPage($pagename,'read');
    PCache($pagename, $page); // <--- does this needs to be set
    $new = $page;
    $new['text'] = 'replaced text';
    $new['csum'] = $ChangeSummary;
    if ($ChangeSummary) $new["csum:$Now"] = $ChangeSummary;
    // $EnablePost = 1 // <--- does this needs to be set
    UpdatePage($pagename, $page, $new); 
    if ($IsPagePosted) {
      //Redirect($pagename); // <--- does this needs to be set, gives infinite 
redirect loop
      $IsPagePosted = false;

1. After update it gives error -  
Warning: array_keys() [function.array-keys]: The first argument should be an 
array in /var/www/pmwiki/2.2.4/pmwiki.php on line 1660
2. Though the page is saved the history page or probably the diff section does 
not get saved properly.

Maybe I am missing some steps?

On Saturday 09 Jan 2010 7:54:58 am you wrote:
> On Friday 08 January 2010 22:39:54, V.Krishn wrote :
> > Will it be ok if I just called the function UpdatePage() with required
> > parameters, i.e pagename, $page (original page array) and $new page
> > array, in which only $new['text'] is modified
> Hello. Yes, it should be ok.
> >  or I need to also calculate some
> >  other values in the $new array, like $new ['ctime'] and $new ['diff']?
> No. The functions called by UpdatePage() will calculate them.
> Thanks,
> Petko


More information about the pmwiki-users mailing list