View Issue Details

This bug affects 1 person(s).
 2
IDProjectCategoryView StatusLast Update
18396Bug reportsSurvey editingpublic2022-10-04 15:19
Reportergabrieljenik Assigned To 
PrioritynoneSeveritypartial_block 
Status confirmedResolutionopen 
Product Version5.3.x 
Summary18396: Quesiton model: Validators created by rules are not refreshed when attributes change
Description

Caught while reviewing 18323

When using attribute assignments (as it was fixed on 18323), validators are loaded before setting the attributes.
Some rules are added as validators conditionally, depending on the attribute values.
Then the rules set (final validators loaded) may not match the attributes which are later set.

Some rules need to be changed to validator functions as to be able to react dynamically to changes in the attributes, as opposed to how currently is done, statically when creating validators.

It is to highlight that validators, once created, are not refreshed. rules() is not re-run.
That's why this fails.

Steps To Reproduce

Same as in 18323
Debug a bit to be able to see the error.

Ex rule to be refactored: models/Question.php

/**
         * Question was new or title was updated : we add minor rules.
         * This rules don't broke DB, only potential “ExpressionScript Engine” issue.
         * usage of 'archiveimport' scenaruio for import LSA (survey archive) file
         **/
        if (empty($this->parent_qid)) {
            /* Unicity for ExpressionManager */
            $aRules[] = array('title', 'unique', 'caseSensitive' => true,
                'criteria' => array(
                    'condition' => 'sid=:sid AND parent_qid=0',
                    'params' => array(
                        ':sid' => $this->sid
                        )
                    ),
                'message' => gT('Question codes must be unique.'),
                'except' => 'archiveimport'
            );
TagsNo tags attached.
Bug heat2
Complete LimeSurvey version number (& build)5.3.30
I will donate to the project if issue is resolvedNo
BrowserOpera
Database type & versionmariadb Ver 15.1 Distrib 10.4.25-MariaDB, for Linux (x86_64) using readline 5.1
Server OS (if known)
Webserver software & version (if known)
PHP Version7.4

Relationships

related to 18323 closedgabrieljenik When copying a question with sub-questions, the sub-questions are not copied 

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2022-10-04 15:19

developer   ~72082

But parent_qid came from current situation here. You can not set a parent_qid from 0/empty to 123

Issue History

Date Modified Username Field Change
2022-10-04 15:02 gabrieljenik New Issue
2022-10-04 15:02 gabrieljenik Issue generated from: 18323
2022-10-04 15:02 gabrieljenik Relationship added related to 18323
2022-10-04 15:04 gabrieljenik Status new => confirmed
2022-10-04 15:19 DenisChenu Note Added: 72082
2022-10-04 15:19 DenisChenu Bug heat 0 => 2