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

Michael Klier wrote
> Just to let you know, I filed a bug report (fs#1258) against this patch
> because it breaks the meta-data generation for new pages where i.e.
> "date" is at first empty but not an array which causes the later
> array_merge() to fail. However, I couldn`t come up with a solution up to

Hi Michael & Tom & List

I ended up inserting some extra trim() calls into the meta plugin to fix 
half the problem and then also applied the following to the 
parserutils.php to make the above problem go away (i think), it basically 
breaks out the iff to add an extra } else { so that it can deal with the 
empty case you mention Michael.  Please confirm if this now makes sense:

--- old-wiki/inc/parserutils.php        2007-09-28 22:21:12.000000000 
+0200
+++ new-wiki/inc/parserutils.php        2007-09-28 22:21:12.000000000 
+0200
@@ -289,14 +289,22 @@
 
       if (is_array($value)){
         #FIXME not sure if this is the intended thing:
-        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(!empty($meta['current'][$key])){
+          if (!is_array($meta['current'][$key]))
+            $meta['current'][$key] = array($meta['current'][$key]);
+          $meta['current'][$key] = array_merge($meta['current'][$key], 
$value);
+        } else {
+          $meta['current'][$key] = $value;
+        }
 
         if ($persistent) {
-          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);
+          if(!empty($meta['persistent'][$key])){
+            if(!is_array($meta['persistent'][$key]))
+              $meta['persistent'][$key] = 
array($meta['persistent'][$key]);
+            $meta['persistent'][$key] = 
array_merge($meta['persistent'][$key], $value);
+          } else {
+            $meta['persistent'][$key] = $value;
+          }
         }
       }


The above patch has eliminated these warnings in my httpd error_log:
[Fri Sep 28 21:47: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/2005/10/2005-10-03-204353?do=edit&rev=
[Fri Sep 28 21:47: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/2005/10/2005-10-03-204353?do=edit&rev=


Regards
-ant


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: