[dokuwiki] Re: [patch] don't display zero length files in search

  • From: Robin Getz <rgetz@xxxxxxxxxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Mon, 11 Oct 2010 13:30:03 -0400

On Wed 29 Sep 2010 09:05, Robin Getz pondered:
> This culls zero length files from search results, and the index.

Ping?

Any other suggestions to get http://www.dokuwiki.org/plugin:redirect
to show "avaliable" links? The only thing I can think of is to change
page_exists to trigger an event that the plugin could capture, but I
would think that would be much higher overhead that the proposed
solution...???

Thanks

> --- a/inc/pageutils.php
> +++ b/inc/pageutils.php
> @@ -232,7 +232,9 @@ function sectionID($title,&$check) {
>   * @author Chris Smith <chris@xxxxxxxxxxxxx>
>   */
>  function page_exists($id,$rev='',$clean=true) {
> -    return @file_exists(wikiFN($id,$rev,$clean));
> +    $pg = wikiFN($id,$rev,$clean);
> +    $ret = @file_exists($pg) && filesize($pg);
> +    return $ret;
>  }
> --- a/inc/search.php
> +++ b/inc/search.php
> @@ -31,6 +31,7 @@ function search(&$data,$base,$func,$opts,$dir='',$lvl=1){
>      if(!$dh) return;
>      while(($file = readdir($dh)) !== false){
>          if(preg_match('/^[\._]/',$file)) continue; //skip hidden files and 
> upper dirs
> +        if(!filesize($base.'/'.$dir.'/'.$file)) continue; // skip zero 
> length files
>          if(is_dir($base.'/'.$dir.'/'.$file)){
>              $dirs[] = $dir.'/'.$file;
>              continue;
> 
> 
-- 
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: