Hi,
While installing DokuWiki, I got a message 'sort function expects an array as first argument, given a string'.
I traced it to the glob function used in the standard plugin 'config' in file:settings\extra.class.php.
So it concerns everybody. The closest existing thread
http://forum.dokuwiki.org/thread/274
didn't mention any solution, so I'll suggest something.
http://seclists.org/fulldisclosure/2005/Sep/0001.html
describes security reasons for which glob is disabled on certain Internet Supplier Servers.
In particular, on Free.fr which is a quite restrictive web hoster,
there will be a warning like 'sort function expects an array as first argument, given a string'.
Looks like a nasty bug.
No! due to site security restrictions, the variable returned by glob is possibly an empty string and not array.
However there is a work-around which works very well. see: function safe_glob in
http://fr.php.net/manual/en/function.glob.php
I suggest integrating this version of safe_glob to do away with apparent bugs on a system that works well otherwise,
even on paranoid servers !
FYI: author: BigueNique at yahoo dot ca
function safe_glob($pattern, $flags=0) {
$split=explode('/',$pattern);
$match=array_pop($split);
$path=implode('/',$split);
if (($dir=opendir($path))!==false) {
$glob=array();
while(($file=readdir($dir))!==false) {
if (fnmatch($match,$file)) {
if ((is_dir("$path/$file"))||(!($flags&GLOB_ONLYDIR))) {
if ($flags&GLOB_MARK) $file.='/';
$glob[]=$file;
}
}
}
closedir($dir);
if (!($flags&GLOB_NOSORT)) sort($glob);
return $glob;
} else {
return false;
}
}
Any comments ?