[pmwiki-users] Re: Using AllRecentChanges as a shared page between fields

chr at home.se chr at home.se
Sat Jul 23 18:44:09 CDT 2005


On Sat, 23 Jul 2005, Patrick R. Michaud wrote:

> On Sat, Jul 23, 2005 at 04:00:50PM +0200, chr at home.se wrote:
> > Would it be possible to have Site.AllRecentChanges be shared page between
> > fields?
> 
> Maybe, if we implement PITS 00459 somehow.  Although, instead of
> repurposing Site.AllRecentChanges I think I'd just configure a new
> Site.FarmRecentChanges page instead.

Using Site.FarmRecentChanges seems much better.

> > However, we could still have two instances of pmwiki.php trying to write
> > to the same file at the same time. Can the locking mechanism handle this,
> > i.e. where is the lock stored?
> 
> By default the locking mechanism doesn't handle this, as the lock
> is managed on a per-field basis.  However, a farm administrator can
> set a farm-wide value for $LockFile, so that all fields share the same
> lock, and then there's no problem.

Ah.. that's an easy solution for my situation. Looking in the source I 
found

	function Lock($op) { 
	  global $WorkDir,$LockFile;
	  SDV($LockFile,"$WorkDir/.flock");
	  mkdirp(dirname($LockFile));

so I assume I could just add the following to my local/farmconfig.php

	$LockFile = "$FarmD/.flock";

as long as pmwiki.php may write to that directory (which it actually can't
in my case). Alternatively, I could simply do

	$WorkDir = $FarmD;

In my case (where $FarmD isn't writable), I'll simply set it as follows

	$LockDir = "$FarmD/$WorkDir/.flock";

and have all fields use .flock/ in the primary fields directory. If this 
sounds reasonable, I can add the above to the cookbook page that talks 
about sharing files.

/Christian

PS. Two comments from glancing at the code. 
* Would it make sense to let Lock() take a second (optional) argument
  that is a pagename, and use that to create a unique lock file?
  I guess the advantage is that you can get locking on a file basis, which
  might be useful if *many* people edit files at the same time.

* The variable $WorkDir doesn't seem very useful...  it's only used in
  Lock(), and to give a default argument to PageStore(). What I really 
  wonder is why $WorkDir isn't used in this assignment

	$WikiDir = new PageStore('wiki.d/$FullName');

* What is the difference (if any) between $WorkDir and $WikiDir?
  ($WorkDir isn't documented AFAICT at pmwiki.org - hint, hint:-)

-- 
Christian Ridderström, +46-8-768 39 44               http://www.md.kth.se/~chr






More information about the pmwiki-users mailing list