View Issue Details

This bug affects 1 person(s).
 2
IDProjectCategoryView StatusLast Update
04697Bug reportsSurvey takingpublic2010-10-28 00:54
Reporterronvdburg Assigned Toc_schmitz  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version1.90+ 
Fixed in Version1.90+ 
Summary04697: PHP Warning at submit with show-empty-group
Description

If submitting a survey in group mode;
when the last group is empty;
and there are no postedfieldnames;
the 'in-array' function complains with the following:
====== error_log =======
PHP Warning: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument in /var/www/html/.../save.php on line 424, referer: http://surveyhost.../survey/index.php

Steps To Reproduce

Select/create a survey in group mode.
Check the config to enable:
$show_empty_group_if_the_last_group_is_hidden = true;

Select/create the last group.
Make all questions in this last group conditional.

Start the survey.
Make sure that no conditions on the last group's questions are met.

You will now see an "empty group" page because the last group is not shown.

Press submit.

Check the error_log.

Additional Information

The PHP in-array function complains if the second argument is empty.

So, replace
... && in_array($value,$postedfieldnames)
with
... && sizeof($postedfieldnames) > 0 && in_array($value,$postedfieldnames)

In other words, check if there are postedfieldnames before trying to use them.

In my uploaded patch, I also moved the end-of-line comment to the next line. Otherwise the code is longer than 80 characters.

TagsNo tags attached.
Attached Files
in_array.patch (1,011 bytes)   
Index: limesurvey/save.php
===================================================================
--- limesurvey/save.php	(revision 9333)
+++ limesurvey/save.php	(working copy)
@@ -434,8 +434,9 @@
                     {
                         $_SESSION[$value]=sanitize_float($_SESSION[$value]);
                     }
-                    elseif ($fieldexists['type']=='D' && in_array($value,$postedfieldnames))  // convert the date to the right DB Format but only if it was posted
+                    elseif ($fieldexists['type']=='D' && sizeof($postedfieldnames) > 0 && in_array($value,$postedfieldnames))
                     {
+                        // convert the date to the right DB Format but only if it was posted
                         $dateformatdatat=getDateFormatData($thissurvey['surveyls_dateformat']);
                         $datetimeobj = new Date_Time_Converter($_SESSION[$value], $dateformatdatat['phpdate']);
                         $_SESSION[$value]=$datetimeobj->convert("Y-m-d");
in_array.patch (1,011 bytes)   
Bug heat2
Complete LimeSurvey version number (& build)9333
I will donate to the project if issue is resolved
Browser
Database type & versionmysql 5.0.77
Server OS (if known)Centos 5.3 / Linux 2.6.18
Webserver software & version (if known)apache 2.2.3
PHP Version5.1.6

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2010-10-25 17:23

administrator   ~13341

Last edited: 2010-10-25 17:24

Thank you! Fixed in rev 9334

c_schmitz

c_schmitz

2010-10-28 00:54

administrator   ~13357

Fixed in latest 1.90+ release.

Issue History

Date Modified Username Field Change
2010-10-25 16:14 ronvdburg New Issue
2010-10-25 16:14 ronvdburg File Added: in_array.patch
2010-10-25 17:14 c_schmitz Assigned To => c_schmitz
2010-10-25 17:14 c_schmitz Status new => assigned
2010-10-25 17:23 c_schmitz Note Added: 13341
2010-10-25 17:23 c_schmitz Status assigned => resolved
2010-10-25 17:23 c_schmitz Fixed in Version => 1.90+
2010-10-25 17:23 c_schmitz Resolution open => fixed
2010-10-25 17:24 c_schmitz Note Edited: 13341
2010-10-28 00:54 c_schmitz Note Added: 13357
2010-10-28 00:54 c_schmitz Status resolved => closed