[pmwiki-users] Another Problem caused by recent PmWiki updates

Patrick R. Michaud pmichaud at pobox.com
Tue Mar 13 15:19:59 CDT 2007


On Tue, Mar 13, 2007 at 06:25:05PM +0000, Hans wrote:
> > Hmm.  I don't think anything has changed in either 
> > MatchPageNames or FmtPageName, so I'm not sure where the
> > problem would be.  What's the value of $pagename at the time this
> > call is made?

Oops, I was wrong.  In beta32 I changed the algorithm for
doing wildcard matches within MatchPageNames(), so there is a
change there that could be the issue.

One possible source of a problem is that starting with beta32,
spaces aren't valid wildcard pattern separators.  I made this 
change because otherwise there's not a good way to match page 
variables containing spaces -- e.g., the following would
search for "Patrick" and "Michaud" but not "Patrick Michaud":

    (:pagelist $:Author="Patrick Michaud" :)

So, I see two possibilities here:

1.  Change the lines in fox.php to use commas as the
    wildcard separators, as in:

    $permit = (boolean)MatchPageNames($targetname,
                       FmtPageName(implode(',', $FoxNameFmt), $pagename));

2.  I can fix MatchPageNames() to treat spaces as wildcard
    separators.

The downside to #2 is that this would mean that spaces sometimes
act as separators (when matching page names) and sometimes would
not be separators (when matching page variables, or other wildcard
matches).  I think I'd prefer to consistently use commas to specify
multiple wildcard patterns, as I think this will cause less
overall confusion.

> SDVA($FoxNameFmt, array(
>     '-$SiteGroup.*',       // no pages in SiteGroup
>     '-PmWiki.*',           // no pages in PmWiki group
>   //  '{$FullName}-Talk',    // page with -Talk prefix in current group
>   //  '{$FullName}-Discuss', // page with -Discuss prefix in current group 
>     '{$Group}.*',          // all pages in current group    
>     '*.{$Name}-Comment',   // pages with -Comment prefix in any group
>     'Comments.{$Group}-{$Name}', //pages in Comments group with name 'Group-Name'
>   //  'Comments.*',          // all pages in Comments group
>   //  '*.*',                 // all pages
> ));
> 
> Now in config.php I had defined
> 
> $FoxNameFmt[] = 'Test*.*';
> include_once("$FarmD/cookbook/fox.php");

Hmm, I don't know that this will do what you want -- we should
check this.  The SDVA() function is really intended to add *keyed*
items into an array, so passing it an unkeyed array (like the
above) may result in duplicate indexes/keys, and cause values 
to be omitted.

In particular, in the code above, the '-$SiteGroup.*' value is
likely to not be stored in $FoxNameFmt because it's at index 0,
and $FoxNameFmt already has a value stored at index 0 ('Test*.*').

I know that SDVA() didn't change between beta31 and beta35, so
I suspect it's not doing what you want in either release.

> What is the correct way of adding an entry to the array, which is
> defined with SDVA? 

The correct way of adding entries to an array is to simply use
array_merge, as in:

  $FoxNameFmt = array_merge((array)$FoxNameFmt, array(
      '-$SiteGroup.*',       // no pages in SiteGroup
      '-PmWiki.*',           // no pages in PmWiki group
    //  '{$FullName}-Talk',    // page with -Talk prefix in current group
    //  '{$FullName}-Discuss', // page with -Discuss prefix in current group 
      '{$Group}.*',          // all pages in current group    
      '*.{$Name}-Comment',   // pages with -Comment prefix in any group
      'Comments.{$Group}-{$Name}', //pages in Comments group with name 'Group-Name'
    //  'Comments.*',          // all pages in Comments group
    //  '*.*',                 // all pages
  ));

Pm



More information about the pmwiki-users mailing list