[pmwiki-devel] strange conversions: a FmtPageName bug

Patrick R. Michaud pmichaud at pobox.com
Sun Mar 9 09:36:58 CDT 2008


On Sun, Mar 09, 2008 at 12:32:58PM +0000, Hans wrote:
> 
> Out of curiosity: what makes '$t' into a global?
> It is hard to search the code for this.

Any variabes that aren't part of a function are global.
This would include variables that are used in the course
of initializing PmWiki or any customizations and/or
recipes.

For example, lines 345-350 of pmwiki.php contain:

  $keys = array_keys($AuthCascade);
  while ($keys) {
    $k = array_shift($keys); $t = $AuthCascade[$k];
    if (in_array($t, $keys))
      { unset($AuthCascade[$k]); $AuthCascade[$k] = $t; array_push($keys, $k); }
  }

which creates global variables for $keys, $k, and $t.

The way to prevent these from becoming global would be
to put all of initialization steps into separate functions
(thus making these variables local).  While we could do this
for PmWiki, we'd still have global variables leaking out
via recipes and local customizations.

Another possibility might be to adjust FmtPageName so that
it only substitutes variables that begin with a capital letter.

Pm



More information about the pmwiki-devel mailing list