Fix PHP Notice: Array to string conversion in validate.inc.php
authorNicolas Iooss <nicolas.iooss_git@polytechnique.org>
Sun, 29 Dec 2013 11:03:52 +0000 (12:03 +0100)
committerNicolas Iooss <nicolas.iooss_git@polytechnique.org>
Sun, 29 Dec 2013 11:03:52 +0000 (12:03 +0100)
Validate::iterate() builds a SQL query that involves an array of WHERE filters.
When this array is empty, it was incorrectly kept as is, thus triggering a PHP
Notice.

Note: this error is not fatal as the following statement is a valid SQL query:
SELECT data, DATE_FORMAT(stamp, "%Y%m%d%H%i%s") FROM requests Array ORDER BY stamp;

include/validations.inc.php

index 390e81b..2840965 100644 (file)
@@ -440,6 +440,8 @@ abstract class Validate
         }
         if (!empty($where)) {
             $where = 'WHERE ' . implode('AND', $where);
+        } else {
+            $where = '';
         }
         $it = XDB::iterRow('SELECT  data, DATE_FORMAT(stamp, "%Y%m%d%H%i%s")
                               FROM  requests