Skip to content

Commit

Permalink
Fixed issue SQL error on load (bug related to commit/revision 12152)
Browse files Browse the repository at this point in the history
Dev bad DELETE syntax

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@12166 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
TMSWhite committed Jan 23, 2012
1 parent ffc8f16 commit c17af23
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions classes/eval/LimeExpressionManager.php
Expand Up @@ -167,6 +167,9 @@ public static function SetEMLanguage($lang=NULL)
public static function UpgradeConditionsToRelevance($surveyId=NULL, $qid=NULL)
{
LimeExpressionManager::SetDirtyFlag(); // set dirty flag even if not conditions, since must have had a DB change
// Cheat and upgrade question attributes here too.
self::UpgradeQuestionAttributes(true,$surveyId,$qid);

$releqns = self::ConvertConditionsToRelevance($surveyId,$qid);
$num = count($releqns);
if ($num == 0) {
Expand All @@ -179,8 +182,6 @@ public static function UpgradeConditionsToRelevance($surveyId=NULL, $qid=NULL)
db_execute_assoc($query);
$queries[] = $query;
}
// Cheat and upgrade question attributes here too.
$queries = array_merge($queries, self::UpgradeQuestionAttributes(true,$surveyId,$qid));
LimeExpressionManager::SetDirtyFlag();
return $queries;
}
Expand Down Expand Up @@ -5317,6 +5318,7 @@ public static function UpgradeQuestionAttributes($changeDB=false,$surveyid=NULL,
'min_num_value_sgqa' => 'min_num_value',
'num_value_equals_sgqa' => 'equals_num_value',
);
$reverseAttributeMap = array_flip($attibutemap);
foreach ($qattrs as $qid => $qattr)
{
$updates = array();
Expand All @@ -5340,30 +5342,12 @@ public static function UpgradeQuestionAttributes($changeDB=false,$surveyid=NULL,
foreach ($updates as $key=>$value)
{
$query = "UPDATE ".db_table_name('question_attributes')." SET value='".addslashes($value)."' WHERE qid=".$qid." and attribute='".addslashes($key)."';";
$queries[] = $query;
}
}
foreach ($attibutemap as $key=>$value)
{
$query = "DELETE FROM ".db_table_name('question_attributes');
if (!is_null($surveyid))
{
$query .= ", ".db_table_name('questions');
}
$query .= " WHERE ".db_table_name('question_attributes').".attribute='" . $key . "'";
if (!is_null($onlythisqid))
{
$query .= " AND ".db_table_name('question_attributes').".qid=".$onlythisqid;
}
else if (!is_null($surveyid))
{
$query .= " AND ".db_table_name('question_attributes').".qid = ".db_table_name('questions').".qid";
$query .= " AND ".db_table_name('questions').".sid=".$surveyid;
$queries[] = $query;
$query = "DELETE FROM ".db_table_name('question_attributes')." WHERE qid=".$qid." and attribute='".addslashes($reverseAttributeMap[$key])."';";
$queries[] = $query;

}
$query .= ";";
$queries[] = $query;
}
// now update the datbase
foreach ($queries as $query)
{
db_execute_assoc($query);
Expand Down

0 comments on commit c17af23

Please sign in to comment.