[pmwiki-users] PmWiki 2.2-beta12 - UpdatePage() released
editor at fast.st
Fri Oct 6 17:44:26 CDT 2006
On 10/6/06, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> 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.
It's not a big deal to me either way, but thought I'd mention the same
question crossed my mind. I initially assumed this function would
simply resave the same page--with any new changes. IE--read page,
change page[text] or page[title], then update the same page. Using
two page variables seemed a rather counterintuitive, and unnecessaily
complex way to do it.
If you did it this way you wouldn't have to do a second file read
either (eh, unless to make the diff?). Perhaps you could store the new
text as page[updatetext] and then work the diff that way. Just a
thought. Either way is fine with me.
More information about the pmwiki-users