From: SourceForge.net <no...@so...> - 2010-02-22 09:28:13
|
Bugs item #2956482, was opened at 2010-02-22 09:24 Message generated for change (Comment added) made by You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108956&aid=2956482&group_id=8956 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: User Group: 2.1.3 Status: Open Resolution: None Priority: 5 Private: No Submitted By: mike () Assigned to: Nobody/Anonymous (nobody) Summary: Dashboard displays incorrect "Last Access" date Initial Comment: Related: 2784037 If a survey has multiple responses, the "Last Access" column in the dashboard may display an incorrect date. The column is built from a $responses array which ultimately is generated in survey_get_responses function in espsurvey.inc. The root cause is this block of code from survey_get_from_sql: if (isset($surveys[$id])) { if ($needsConversion) { // we've collided, but not yet converted to an array: do so $surveys[$id] = array ($surveys[$id]); $needsConversion = false; } $surveys[$id][] = $row; } else { $surveys[$id] = $row; } $row is an array. When there is only one $row in the SQL result, $surveys[$id] is equal to that single $row. If a second $row is found, $surveys[$id] is turned into an array of arrays, with each $row being an entry in the "second dimension" of the array. It appears the line: $surveys[$id] = array ($surveys[$id]); is intended to convert the current value of $surveys[$id] into an entry in a new array of arrays. However, $surveys[$id] is expanded, and rather than adding a reference to an array, it simply adds all the name->value pairs currently in $surveys[$id] to a new array. $surveys[$id] looks like [survey_id] => 3 [username] => foobar [submitted] => 2010-02-12 03:25:29 [complete] => Y [ip] => 1.1.1.1 [0] => Array ( 2 [survey_id] => 3 [username] => foobar [submitted] => 2010-02-12 03:29:34 [complete] => Y [ip] => 1.1.1.1 ) instead of the intended [0] => Array([survey_id] => 3 [username] => foobar [submitted] => 2010-02-12 03:25:29 [complete] => Y [ip] => 1.1.1.1) [1] => Array ( 2 [survey_id] => 3 [username] => foobar [submitted] => 2010-02-12 03:29:34 [complete] => Y [ip] => 1.1.1.1 ) Back in dashboard.php, the $array['submitted'] is tested, it exists, and thus it is assumed that is the ONLY entry. Rather than iterating through the rest of the array, that first date is simply returned. That explanation feels terrible to me, hopefully it makes sense to anyone else encountering this issue. In my case, I solved it by creating a new function response_get_from_sql, identical in most ways except it starts by assuming there are multiple values to be inserted in the array, never mucking about with needsConversion and so forth in the first place. Inelegant perhaps, but I didn't want to screw around survey_get_from_sql. ---------------------------------------------------------------------- >Comment By: mike () Date: 2010-02-22 09:28 Message: Oh, mentioned bug 2784037 as related because this also solves the "Some Finished, some Incomplete" bug that user reported. They misdiagnosed the exact cause but did identify the same area of code as the root. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108956&aid=2956482&group_id=8956 |