[dokuwiki] Re: possible bug in parserutils.php patch on the 19th of September...

  • From: Chris Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 29 Sep 2007 00:08:23 +0100

Hi,

There seems to be alot of candidate patches flying around concerning one
small piece of code.  Its not confidence inspiring that the patches have
been thought through.

I've taken a look at the current code and the original patch introducing
metadata.  It shouldn't be possible for any of the protected metadata
keys to have non-array values.  Ie. They can be empty or hold arrays. 
For me that means the code should look like this ...

      if (is_array($value)) {
        $meta['current'][$key] = !empty($meta['current'][$key]) ?
array_merge($meta['current'][$key],$value) : $value;

        if ($persistent) {
          $meta['persistent'][$key] = !empty($meta['persistent'][$key])
? array_merge($meta['persistent'][$key],$value) : $value;
        }
      }

If using the above code still causes warnings in your php logs,  then I
reckon the metadata itself has somehow gotten incorrect(*).  The best
place to solve that is to introduce some code in the retrieval function
(p_read_metada) to correct the metadata before handing it on to the
access functions - and to write the corrected metadata back to the
source file.  Something of that nature is probably necessary already as
there are empty values in those keys on my wiki (e.g. [0] => null).

(*) Which could indicate a bug somewhere else in DW.  If anyone does try
the above code and you still get warnings, feel free to email the
metadata portion of ?do=debug output to me.  Data values in the keys
aren't important so feel free to anonymise them by converting them all
to some character or other (e.g. X).

If anyone thinks I've got this wrong, please reply as soon as, otherwise
I'll forward this patch to Andi early next week.

-- Chris

PS.  Its feasible that a syntax plugin could add invalid data to one of
these keys - I didn't check the metadata renderer to see if that is
possible.  If it is, it should really be the responsibility of the
renderer to correct the data before writing it out.

-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: