Skip to content
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

fix(migration): Replace execute() with executeQuery() and executeStatement() for improved query execution #2551

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/Migration/Version010200Date20200323141300.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@

$qb_fetch->select('id', 'hash', 'title', 'description', 'owner', 'created', 'access', 'expire', 'is_anonymous', 'unique')
->from('forms_events');
$cursor = $qb_fetch->execute();
$cursor = $qb_fetch->executeQuery();

Check warning on line 210 in lib/Migration/Version010200Date20200323141300.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version010200Date20200323141300.php#L210

Added line #L210 was not covered by tests
while ($event = $cursor->fetch()) {
$newAccessJSON = $this->convertAccessList($event['access']);

Expand All @@ -223,7 +223,7 @@
'is_anonymous' => $qb_restore->createNamedParameter($event['is_anonymous'], IQueryBuilder::PARAM_BOOL),
'submit_once' => $qb_restore->createNamedParameter($event['unique'], IQueryBuilder::PARAM_BOOL)
]);
$qb_restore->execute();
$qb_restore->executeStatement();

Check warning on line 226 in lib/Migration/Version010200Date20200323141300.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version010200Date20200323141300.php#L226

Added line #L226 was not covered by tests
$id_mapping['events'][$event['id']] = [
'newId' => $qb_restore->getLastInsertId(), //Store new form-id to connect questions to new form.
'nextQuestionOrder' => 1 //Prepare for sorting questions
Expand All @@ -237,7 +237,7 @@

$qb_fetch->select('id', 'form_id', 'form_question_type', 'form_question_text')
->from('forms_questions');
$cursor = $qb_fetch->execute();
$cursor = $qb_fetch->executeQuery();

Check warning on line 240 in lib/Migration/Version010200Date20200323141300.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version010200Date20200323141300.php#L240

Added line #L240 was not covered by tests
while ($question = $cursor->fetch()) {
//In case the old Question would have been longer than current possible length, create a warning and shorten text to avoid Error on upgrade.
if (strlen($question['form_question_text']) > 2048) {
Expand All @@ -252,7 +252,7 @@
'type' => $qb_restore->createNamedParameter($this->questionTypeMap[$question['form_question_type']], IQueryBuilder::PARAM_STR),
'text' => $qb_restore->createNamedParameter($question['form_question_text'], IQueryBuilder::PARAM_STR)
]);
$qb_restore->execute();
$qb_restore->executeStatement();

Check warning on line 255 in lib/Migration/Version010200Date20200323141300.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version010200Date20200323141300.php#L255

Added line #L255 was not covered by tests
$id_mapping['questions'][$question['id']]['newId'] = $qb_restore->getLastInsertId(); //Store new question-id to connect options to new question.
}
$cursor->closeCursor();
Expand All @@ -263,7 +263,7 @@

$qb_fetch->select('question_id', 'text')
->from('forms_answers');
$cursor = $qb_fetch->execute();
$cursor = $qb_fetch->executeQuery();

Check warning on line 266 in lib/Migration/Version010200Date20200323141300.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version010200Date20200323141300.php#L266

Added line #L266 was not covered by tests
while ($answer = $cursor->fetch()) {
//In case the old Answer would have been longer than current possible length, create a warning and shorten text to avoid Error on upgrade.
if (strlen($answer['text']) > 1024) {
Expand All @@ -276,7 +276,7 @@
'question_id' => $qb_restore->createNamedParameter($id_mapping['questions'][$answer['question_id']]['newId'], IQueryBuilder::PARAM_INT),
'text' => $qb_restore->createNamedParameter($answer['text'], IQueryBuilder::PARAM_STR)
]);
$qb_restore->execute();
$qb_restore->executeStatement();

Check warning on line 279 in lib/Migration/Version010200Date20200323141300.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version010200Date20200323141300.php#L279

Added line #L279 was not covered by tests
}
$cursor->closeCursor();

Expand All @@ -287,7 +287,7 @@
$qb_fetch = $this->connection->getQueryBuilder();
$qb_fetch->select('id')
->from('forms_events');
$cursor = $qb_fetch->execute();
$cursor = $qb_fetch->executeQuery();

Check warning on line 290 in lib/Migration/Version010200Date20200323141300.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version010200Date20200323141300.php#L290

Added line #L290 was not covered by tests
while ($tmp = $cursor->fetch()) {
$event_structure[$tmp['id']] = $tmp;
}
Expand All @@ -299,7 +299,7 @@
$qb_fetch->select('id', 'form_question_text')
->from('forms_questions')
->where($qb_fetch->expr()->eq('form_id', $qb_fetch->createNamedParameter($event['id'], IQueryBuilder::PARAM_INT)));
$cursor = $qb_fetch->execute();
$cursor = $qb_fetch->executeQuery();

Check warning on line 302 in lib/Migration/Version010200Date20200323141300.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version010200Date20200323141300.php#L302

Added line #L302 was not covered by tests
while ($tmp = $cursor->fetch()) {
$event_structure[$event['id']]['questions'][] = $tmp;
}
Expand All @@ -317,7 +317,7 @@

$qb_fetch->select('id', 'form_id', 'user_id', 'vote_option_id', 'vote_option_text', 'vote_answer')
->from('forms_votes');
$cursor = $qb_fetch->execute();
$cursor = $qb_fetch->executeQuery();

Check warning on line 320 in lib/Migration/Version010200Date20200323141300.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version010200Date20200323141300.php#L320

Added line #L320 was not covered by tests
while ($vote = $cursor->fetch()) {
//If the form changed, if the user changed or if vote_option_id became smaller than last one, then a new submission is interpreted.
if (($vote['form_id'] !== $last_vote['form_id']) || ($vote['user_id'] !== $last_vote['user_id']) || ($vote['vote_option_id'] < $last_vote['vote_option_id'])) {
Expand All @@ -327,7 +327,7 @@
'user_id' => $qb_restore->createNamedParameter($vote['user_id'], IQueryBuilder::PARAM_STR),
'timestamp' => $qb_restore->createNamedParameter(time(), IQueryBuilder::PARAM_STR) //Information not available. Just using Migration-Timestamp.
]);
$qb_restore->execute();
$qb_restore->executeStatement();

Check warning on line 330 in lib/Migration/Version010200Date20200323141300.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version010200Date20200323141300.php#L330

Added line #L330 was not covered by tests
$id_mapping['currentSubmission'] = $qb_restore->getLastInsertId(); //Store submission-id to connect answers to submission.
}
$last_vote = $vote;
Expand All @@ -353,7 +353,7 @@
'question_id' => $qb_restore->createNamedParameter($id_mapping['questions'][$oldQuestionId]['newId'], IQueryBuilder::PARAM_STR),
'text' => $qb_restore->createNamedParameter($vote['vote_answer'], IQueryBuilder::PARAM_STR)
]);
$qb_restore->execute();
$qb_restore->executeStatement();

Check warning on line 356 in lib/Migration/Version010200Date20200323141300.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version010200Date20200323141300.php#L356

Added line #L356 was not covered by tests
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Migration/Version020202Date20210311150843.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

$qb_fetch->select('id', 'access_json')
->from('forms_v2_forms');
$cursor = $qb_fetch->execute();
$cursor = $qb_fetch->executeQuery();

Check warning on line 41 in lib/Migration/Version020202Date20210311150843.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version020202Date20210311150843.php#L41

Added line #L41 was not covered by tests

$qb_update->update('forms_v2_forms')
->set('access_json', $qb_update->createParameter('access_json'))
Expand All @@ -63,7 +63,7 @@
if ($update_necessary) {
$qb_update->setParameter('id', $row['id'], IQueryBuilder::PARAM_INT)
->setParameter('access_json', json_encode($access), IQueryBuilder::PARAM_STR);
$qb_update->execute();
$qb_update->executeStatement();

Check warning on line 66 in lib/Migration/Version020202Date20210311150843.php

View check run for this annotation

Codecov / codecov/patch

lib/Migration/Version020202Date20210311150843.php#L66

Added line #L66 was not covered by tests
}
}
$cursor->closeCursor();
Expand Down
Loading