View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
16175Bug reportsOtherpublic2020-12-30 19:27
ReporterJmantysalo Assigned ToDenisChenu  
PrioritynoneSeveritytweak 
Status closedResolutionfixed 
Product Version4.1.16 
Fixed in Version4.2.2 
Summary16175: statCountIf returns nothing for first participant
Description

statCountIf(...) returns zero, if there is at least one response already, and none of the responses match the condition. However for the first participant it returns nothing.

TagsNo tags attached.
Attached Files
Bug heat8
Complete LimeSurvey version number (& build)Versio 4.1.17+200414
I will donate to the project if issue is resolvedNo
Browser
Database type & versionN/A
Server OS (if known)
Webserver software & version (if known)
PHP VersionN/A

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2020-04-23 11:09

developer   ~57334

… PHP function return 0 … WTF

DenisChenu

DenisChenu

2020-04-23 11:38

developer   ~57335

Issue in https://github.com/LimeSurvey/LimeSurvey/commit/a83531f716f4584272dc3aaf5d214880c6579de4

$result = $result ? $result : false; then no way to return 0 or "" etc … can send only false …

DenisChenu

DenisChenu

2020-04-23 11:54

developer   ~57337

https://github.com/LimeSurvey/LimeSurvey/pull/1409

Can someone check if return null or 0 or "" can broke something in JS ?

My opinion : no … only NAN can broke something

ollehar

ollehar

2020-04-23 13:00

administrator   ~57339

Can @Jmantysalo test this, please? I don't have time.

DenisChenu

DenisChenu

2020-04-23 13:05

developer   ~57340

@ollehar : it's not this issue,

I update something done before, but don't know why …

This issue is fixed with my fix, but touch to Expression core …

Jmantysalo

Jmantysalo

2020-04-23 15:29

reporter   ~57341

I tested, this works.

DenisChenu

DenisChenu

2020-04-23 15:44

developer   ~57342

@cdorin : i know it's the good fix, but i update a line by Markus.
I don't understand wht Markus add it, maybe there are specific JS where a value returned by a function can throw error in JS ?

If some of other dev have an idea : tell me. Else : i merge it tomorrow.

DenisChenu

DenisChenu

2020-04-24 09:39

developer   ~57352

Thanks @JHoeck to review :)

Do you know what (false) value can broke JS ? empty array maybe ? But if a function return an array : i can be an error to use it in JS like this.

My opinion on this fix : only NAN return must be updated $result = $result ? $result : false; not.

Else : alternative option

if(is_null($result) || (is_array($result) && count($result) === 0)) {
    $result = false;
}

I don't like to add a test if it's not needed

DenisChenu

DenisChenu

2020-05-04 11:48

developer   ~57521

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=29957

cdorin

cdorin

2020-12-30 19:27

reporter   ~61357

fixed in 4.4.0 rc1

Related Changesets

LimeSurvey: master 15477d8b

2020-05-04 11:42:23

DenisChenu


Committer: GitHub Details Diff
Fixed issue 16175: statCountIf returns nothing for first participant

Dev: $result = $result ? $result : false; can never return 0
Dev: php function can return null, false, 0 "" …
Dev: Add test for "0" to be returned
Affected Issues
16175
mod - application/helpers/expressions/em_core_helper.php Diff File
mod - tests/data/surveys/survey_archive_statCountFunctionsTest.lsa Diff File
mod - tests/functional/acceptance/15246-fixed-em-function/FixedFunctionExpressionPluginTest.php Diff File

Issue History

Date Modified Username Field Change
2020-04-23 10:50 Jmantysalo New Issue
2020-04-23 10:50 Jmantysalo File Added: limesurvey_survey_585752.lss
2020-04-23 10:58 ollehar Assigned To => DenisChenu
2020-04-23 10:58 ollehar Status new => assigned
2020-04-23 11:09 DenisChenu Note Added: 57334
2020-04-23 11:38 DenisChenu Note Added: 57335
2020-04-23 11:54 DenisChenu Assigned To DenisChenu => ollehar
2020-04-23 11:54 DenisChenu Status assigned => ready for testing
2020-04-23 11:54 DenisChenu Note Added: 57337
2020-04-23 13:00 ollehar Note Added: 57339
2020-04-23 13:00 ollehar Assigned To ollehar =>
2020-04-23 13:05 DenisChenu Note Added: 57340
2020-04-23 15:29 Jmantysalo Note Added: 57341
2020-04-23 15:43 DenisChenu Assigned To => cdorin
2020-04-23 15:44 DenisChenu Note Added: 57342
2020-04-23 16:51 JHoeck Assigned To cdorin => JHoeck
2020-04-24 09:39 DenisChenu Note Added: 57352
2020-05-04 11:48 DenisChenu Changeset attached => LimeSurvey master 15477d8b
2020-05-04 11:48 DenisChenu Note Added: 57521
2020-05-04 11:48 DenisChenu Assigned To JHoeck => DenisChenu
2020-05-04 11:48 DenisChenu Resolution open => fixed
2020-05-07 16:20 DenisChenu Status ready for testing => resolved
2020-05-07 16:20 DenisChenu Fixed in Version => 4.2.2
2020-12-30 19:27 cdorin Note Added: 61357
2020-12-30 19:27 cdorin Status resolved => closed