Skip to content

Commit 488b659

Browse files
committed
fix(question): SQL errors when deleting a question
Signed-off-by: Thierry Bugier <[email protected]>
1 parent bc170a7 commit 488b659

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

inc/question.class.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -666,14 +666,13 @@ public function post_purgeItem() {
666666
// Update order of questions
667667
$order = $this->fields['order'];
668668
$sectionFk = PluginFormcreatorSection::getForeignKeyField();
669-
$DB->update(
670-
$table,
671-
new QueryExpression("`order` = `order` - 1"),
672-
[
673-
'order' => ['>', $order],
674-
$sectionFk => $this->fields[$sectionFk]
675-
]
676-
);
669+
$sectionId = $this->fields[$sectionFk];
670+
$order = $this->fields['order'];
671+
$DB->query("
672+
UPDATE `$table`
673+
SET `order` = `order` - 1
674+
WHERE `order` > '$order' AND `$sectionFk` = '$sectionId'
675+
");
677676

678677
// Always show questions with conditional display on the question being deleted
679678
$questionId = $this->fields['id'];
@@ -686,7 +685,7 @@ public function post_purgeItem() {
686685
'id' => new QuerySubquery([
687686
'SELECT' => self::getForeignKeyField(),
688687
'FROM' => $condition_table,
689-
'WHERE' => ['show_field' => $questionId]
688+
'WHERE' => ['plugin_formcreator_questions_id' => $questionId]
690689
])
691690
]
692691
);
@@ -696,7 +695,7 @@ public function post_purgeItem() {
696695
[
697696
'OR' => [
698697
self::getForeignKeyField() => $questionId,
699-
'show_field' => $questionId
698+
'plugin_formcreator_questions_id' => $questionId
700699
]
701700
]
702701
);

0 commit comments

Comments
 (0)