00633: Categories are incorrectly group qualified in pagelists of trails (or filtered out entirely)

Summary: Categories are incorrectly group qualified in pagelists of trails (or filtered out entirely)
Created: 2006-01-04 13:20
Status: Open - (was: Closed - fixed in 2.1.beta21)
Category: Bug
Assigned:
Priority: 43
Version: 2.0
OS: Debian Linux (unstable)/Apache 2.0.55/PHP 5.0.5

Description:

When using a category in a trail such as:

 
   page: MyGroup.FooTrail

   * [[Foo.Bar]]
   * [[Foo.MiliBar]]
   * [[!Silly]]
   ...

and trying to do a paglist on it using:

 
     (:pagelist trail=MyGroup.FooTrail:)

the category ends up getting listed as a page in the MyGroup group, as MyGroup.Silly.

Analysis:

There are two problems and they both occur in the trails.php ReadTrails() function here:

    if (!preg_match("/^([#*:]+) \\s*
          (\\[\\[([^:#!|][^|:]*?)(\\|.*?)?\\]\\]($SuffixPattern)
          | (($GroupPattern([\\/.]))?$WikiWordPattern)) (.*)/x",$x,$match))
         continue;
      if (@$match[6]) {
         if (!$LinkWikiWords) continue;
         $tgt = MakePageName($trailname,$match[6]);
      } else $tgt = MakePageName($trailname,$match[3]);

  1. Categories are explicitly filtered out on the second line.
  2. The $match[3] on the last line will get set to !Silly and then passed to MakePageName() which returns the wrong answer: MyGroup.Silly.

Proposed Fix:

  1. Simply remove the ! on the second line and Categories will no longer be filtered.
  2. I'm not sure if MakePageName() should be able to handle this correctly, but one way to intercept it before it even gets there is to add $CategoryGroup to the gloabls for the ReadTrail() function and to add this line:
$match[3] = preg_replace("|^\!|", "$CategoryGroup.", $match[3]);
right before the line:
if (@$match[6]) {
With this patch, $match[3] will end up like Category.Silly, MakePageName() handles that properly.

A Test for this, at the bottom, the TestCategory is not even available as the next link as it should be.


In the example above this will work it the correct syntax is used

   * [[Foo.Bar]]
   * [[Foo.MiliBar]]
   * [[Category/Silly]]
See also PITS:00447
simon December 06, 2009, at 01:52 PM