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

  • From: Anthony.Caetano@xxxxxxxxxxxx
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Fri, 28 Sep 2007 00:31:49 +0200

Hi Tom & List

The subject is presumptous of me, but I have been struggling to get old 
pages into a blog using Ester's blog plugin.  The create dates were all 
wrong.  So I scripted the insertion of the ~~META:date created = 
YYYY-MM-DD HH:MM:SS~~, but it didn't help.

Eventually I found that I could print the metadata, and it showed:
Array
(
    [current] => Array
        (
            [last_change] => Array
....
            [] => Array
                (
                    [date created] => 2006-11-20 06:47:31
                    [date issued] => 2006-11-20 06:47:31
                )
...

I had errors such as this in my httpd's error_log
[Thu Sep 27 23:30:28 2007] [error] [client 192.168.1.34] PHP Warning: 
array_merge() [<a href='function.array-merge'>function.array-merge</a>]: 
Argument #1 is not an array in /home/www/html/wiki/inc/parserutils.php on 
line 294, referer: 
http://getafix/wiki/ant/journal/2006/11/2006-11-20-064731?do=edit&rev=
[Thu Sep 27 23:30:28 2007] [error] [client 192.168.1.34] PHP Warning: 
array_merge() [<a href='function.array-merge'>function.array-merge</a>]: 
Argument #1 is not an array in /home/www/html/wiki/inc/parserutils.php on 
line 299, referer: 
http://getafix/wiki/ant/journal/2006/11/2006-11-20-064731?do=edit&rev=

Which I had no clue if it was related, but changing the lines affected by 
this patch:
20070919194756-6942e-0986b3711e370a91d8b42665a94c6866ba56811c.gz
$ darcs changes parserutils.php
Wed Sep 19 21:47:56 SAST 2007  Tom N Harris <tnharris@xxxxxxxxxxxxx>
  * Don't create bogus blank entries in metadata
...

I now have a working blog plugin/archive plugin and get metatdata like 
this:
Array
(
    [current] => Array
        (
...
            [date] => Array
                (
                    [0] => 
                    [modified] => 1190931203
                    [created] => 1163998051
                    [issued] => 1163998051
                )


Here is the diff -u:

--- old-wiki/inc/parserutils.php        2007-09-28 00:25:04.000000000 
+0200
+++ new-wiki/inc/parserutils.php        2007-09-28 00:25:04.000000000 
+0200
@@ -289,17 +289,27 @@
 
       if (is_array($value)){
         #FIXME not sure if this is the intended thing:
-        if(!empty($meta['current'][$key]) && 
!is_array($meta['current'][$key]))
+        if(empty($meta['current'][$key]) || 
!is_array($meta['current'][$key]))
           $meta['current'][$key] = array($meta['current'][$key]);
         $meta['current'][$key] = array_merge($meta['current'][$key], 
$value);
 
         if ($persistent) {
-          if(!empty($meta['persistent'][$key]) && 
!is_array($meta['persistent'][$key]))
+          if(empty($meta['persistent'][$key]) || 
!is_array($meta['persistent'][$key]))
             $meta['persistent'][$key] = array($meta['persistent'][$key]);
           $meta['persistent'][$key] = 
array_merge($meta['persistent'][$key], $value);
         }
       }
 
Can someone (Tom?) tell me if this will break something, or if this the 
correct fix for the behaviour I am seeing?  It seemed to me that the logic 
was wrong in the !empty test and its logical &&... however I don't 
understand the code properly...

Regards
-ant
....................................................................................................................

=[ Phone me ]==  +27 21 947 2057  ||  +27 82 466 8512
=[ Find me ]==  head office TW3 F10



Disclaimer
Sanlam Life Insurance Limited - Reg No 1998/021121/06 - Licensed Financial 
Services Provider
Disclaimer and Directors
Alternatively, send a blank email to Disclaimer

Other related posts: