New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev #19452: Improve usage of getQuestionAttributes PrintableSurvey #3789
Dev #19452: Improve usage of getQuestionAttributes PrintableSurvey #3789
Conversation
Dev: simple for question Dev: add specific array for conditions (again array dual scale)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I have added some bug fixes for issues I encountered while testing. Those issues already existed before your changes, but since they broke the test, I fixed them, but for some reason they do not appear in the changes of this PR.
These are the changes I propose:
I do not understand why the changes are not appearing here even though I pushed them
@@ -238,7 +247,7 @@ public function index($surveyid, $lang = null, $bReturn = false) | |||
// cqid == 0 ==> token attribute match | |||
$tokenData = getTokenFieldsAndNames($surveyid); | |||
preg_match('/^{TOKEN:([^}]*)}$/', (string) $distinctrow['cfieldname'], $extractedTokenAttr); | |||
$sExplanation .= "Your " . $tokenData[strtolower($extractedTokenAttr[1])]['description'] . " "; | |||
$sExplanation .= "Your " . ($tokenData[strtolower($extractedTokenAttr[1])]['description'] ?? "") . " "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is null : it's an issue with your Survey data …
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shnoulle you may be correct, but the page should nevertheless not crash even then.
@@ -631,7 +646,7 @@ public function index($surveyid, $lang = null, $bReturn = false) | |||
} | |||
} | |||
|
|||
if ($arQuestion['other'] == 'Y') { | |||
if (($arQuestion['other'] == 'Y') && isset($qidattributes["printable_help"])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qidattributes["printable_help"] not set ? What question type ? It muts be always set to default : else it's another issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shnoulle if it's not set, for whatever reason, then we will have an error. We should not assume it is set unless we are absolutely sure. If we rely on it being set and it is not set, then - issue or not - we have a page crash. Instead, we should fail only for the question if such is the situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shnoulle if it's not set, for whatever reason, then we will have an error. We should not assume it is set unless we are absolutely sure. If we rely on it being set and it is not set, then - issue or not - we have a page crash. Instead, we should fail only for the question if such is the situation.
But you fix another issue in a dev commit. I can not reproduce your issue, maybe there are another issue : we must find and track the original issue !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shnoulle We should not assume it is set unless we are absolutely sure.
If it's not set : it's clearly an issue : code is done to set ALL attributes default value. Set in the database or not.
It's not an issue in this code, but in getQuestionAttribute : if getQuestionAttribute don't set default value : it's a BIG issue !
You mean bugfix on master ? Because it's appear on the current commit and not in master I use debug 2 on PHP8.1 with Sample survey for testing: i don't have any issue . Maybe you must check your survey or if there are another issue I really think we must not fix such issue for example existing QuestionAttribute must always be set to default (printablesurvey) : if not it's an issue in getQuestionAttribute |
Maybe you need to https://manual.limesurvey.org/Check_data_integrity/en for testing ? |
} | ||
//$distinctrow | ||
$x++; | ||
} | ||
$s++; | ||
} | ||
|
||
$qinfo = LimeExpressionManager::GetQuestionStatus($arQuestion['qid']); | ||
//Defaulting to dummy array to avoid crashes when qinfo is not found for this question | ||
$qinfo = LimeExpressionManager::GetQuestionStatus($arQuestion['qid']) ?? [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If qinfo return null : there are an issue in ExpressionManager not in this commit !
Or in your survey (old question not deleted)
Or in session reset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shnoulle I did not claim that your commit introduced the errors. My claim is that I have seen errors testing with a Survey that was exported from an actual customer's instance. We need to make sure that our code is bullet-proof.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shnoulle I did not claim that your commit introduced the errors. My claim is that I have seen errors testing with a Survey that was exported from an actual customer's instance. We need to make sure that our code is bullet-proof.
Did you try with master : if issues exist in master : it must be fixed in master NOT in another commit …
It did not appear here yesterday, but for some reason it appears now. I will check for Survey errors, but the code should never crash due to this reason. So if you would like to move these fixes someplace else instead, then I'm fine with that, as long as we have the issue fixed and no new issues are created in the process. |
Did you try with master : if issues exist in master : it must be fixed in master NOT in another commit … |
Did it. Here's the result: git hash: 05a9d4e559767: crashes with old version git hash: e2c4a33559767: works Explanation:Those ids are survey ids in my local database, basically results of the query of
How did I test:
(and I changed the id to be passed as a parameter) |
The question is with master, not with your fix. |
The issue was not created by your work. It already existed. But we cannot accept a PR that crashes the page. I understand that you want to create a separate ticket for this purpose, but I'm not sure it is a good idea to do so, because then we create prerequisites for this and thusly we postpone the completion of speed improvement, which, as a result will postpone the switch from LS5 to LS6. These fixes are making the code less volatile and more reliable overall. I have no issues if you create a new ticket in the future with the purpose of fixing these issues, but you will need to detect the problems during your testing then. In this case, they were detected while I tested with your work with some surveys and they were crashing. the page. It would be quite the sacrifice in terms of time needed to create a new ticket, wait for approval, create a new PR, have it accepted, merge it into master, merge master back to this one, fix the merge conflicts that will not exist if we fix the bugs when we see a broken branch. All these prerequisites that we create this way postpones the completion of the task |
It's not about time issue , there are 2 issues on this method (PR with multiple issue)
If you don't want to create mantis issue : create a PR for each and merge it after @tiborpacalat test it.
|
This is the worst part : when you try to find what this line was added, if we can improve and have a cleaner code : know the reason of each update are really great ! |
Dev: simple for question
Dev: add specific array for conditions (again array dual scale)
Dev: avoid multiple call of same question attributes