[pmwiki-users] PmWiki 2.2-beta12 - UpdatePage() released

Patrick R. Michaud pmichaud at pobox.com
Fri Oct 6 09:23:04 CDT 2006

On Fri, Oct 06, 2006 at 02:38:11PM +0200, Thomas -Balu- Walter wrote:
> On Wed, Oct 04, 2006 at 02:50:38PM -0500, Patrick R. Michaud wrote:
> > The UpdatePage line should probably read
> > 
> >     UpdatePage($d, $oldpage, $newpage);
> Just being curious: What's the reason for $oldpage?

Some of the functions that UpdatePage calls need to know
the previous contents of the page in order to work (e.g.,
the one that computes the page history).

Of course, one can argue that UpdatePage should retrieve
the page on behalf of the caller, but since the caller
typically has to read the page _anyway_, as in

    $page = ReadPage($pagename);
    $new = $page;
    $new['text'] = '...New text to be saved...'
    ## now make the call to UpdatePage()

it seemed to make more sense to have the caller pass the 
page structure just read to UpdatePage, instead of requiring 
UpdatePage to perform a second read on top of the first one.

This also allows UpdatePage to have a signature similar
to the other functions in the $EditFunctions list (nice,
but not overwhelmingly important).

It's not too late to switch things if doing so would
make more sense.


More information about the pmwiki-users mailing list