diff --git a/webapp/migrations/Version20210407120356.php b/webapp/migrations/Version20210407120356.php index aeb9993db6..5760135e4d 100644 --- a/webapp/migrations/Version20210407120356.php +++ b/webapp/migrations/Version20210407120356.php @@ -42,7 +42,6 @@ public function up(Schema $schema) : void for ($idx = 0; $idx < $zip->numFiles; $idx++) { $filename = basename($zip->getNameIndex($idx)); $content = $zip->getFromIndex($idx); - $encodedContent = ($content === '' ? '' : ('0x' . strtoupper(bin2hex($content)))); // In doubt make files executable, but try to read it from the zip file. $executableBit = '1'; @@ -52,17 +51,14 @@ public function up(Schema $schema) : void $executableBit = '0'; } $this->connection->executeStatement( - 'INSERT INTO executable_file ' - . '(`immutable_execid`, `filename`, `ranknumber`, `file_content`, `is_executable`) ' - . 'VALUES (' . $immutable_execid . ', "' . $filename . '", ' - . $idx . ', ' . $encodedContent . ', ' - . $executableBit . ')' + 'INSERT INTO executable_file (`immutable_execid`, `filename`, `ranknumber`, `file_content`, `is_executable`) VALUES (?, ?, ?, ?, ?)', + [$immutable_execid, $filename, $idx, $content, $executableBit] ); } $this->connection->executeStatement( - 'UPDATE executable SET immutable_execid = ' - . $immutable_execid . ' WHERE execid = "' . $oldRow['execid'] . '"' + 'UPDATE executable SET immutable_execid = :immutable_execid WHERE execid = :execid', + ['immutable_execid' => $immutable_execid, 'execid' => $oldRow['execid']] ); } diff --git a/webapp/migrations/Version20240511091916.php b/webapp/migrations/Version20240511091916.php index 47fd04c297..c8019b05c0 100644 --- a/webapp/migrations/Version20240511091916.php +++ b/webapp/migrations/Version20240511091916.php @@ -57,21 +57,33 @@ public function getDescription(): string public function up(Schema $schema): void { - foreach (self::COMPILER_VERSION_COMMAND as $lang => $versionCommand) { - $this->addSql("UPDATE language SET compiler_version_command = '" . $versionCommand ."' WHERE langid='" . $lang . "' AND compiler_version_command IS NULL;"); + foreach (self::COMPILER_VERSION_COMMAND as $langid => $versionCommand) { + $this->addSql( + "UPDATE language SET compiler_version_command = :compiler_version_command WHERE langid = :langid AND compiler_version_command IS NULL", + ['compiler_version_command' => $versionCommand, 'langid' => $langid] + ); } - foreach (self::RUNNER_VERSION_COMMAND as $lang => $versionCommand) { - $this->addSql("UPDATE language SET runner_version_command = '" . $versionCommand ."' WHERE langid='" . $lang . "' AND runner_version_command IS NULL;"); + foreach (self::RUNNER_VERSION_COMMAND as $langid => $versionCommand) { + $this->addSql( + "UPDATE language SET runner_version_command = :compiler_version_command WHERE langid = :langid AND runner_version_command IS NULL", + ['compiler_version_command' => $versionCommand, 'langid' => $langid] + ); } } public function down(Schema $schema): void { - foreach (self::COMPILER_VERSION_COMMAND as $lang => $versionCommand) { - $this->addSql("UPDATE language SET compiler_version_command = NULL WHERE langid='" . $lang . "' AND compiler_version_command = '" . $versionCommand ."';"); + foreach (self::COMPILER_VERSION_COMMAND as $langid => $versionCommand) { + $this->addSql( + "UPDATE language SET compiler_version_command = NULL WHERE langid = :langid AND compiler_version_command = :compiler_version_command" + ['compiler_version_command' => $versionCommand, 'langid' => $langid] + ); } - foreach (self::RUNNER_VERSION_COMMAND as $lang => $versionCommand) { - $this->addSql("UPDATE language SET runner_version_command = NULL WHERE langid='" . $lang . "' AND runner_version_command = '" . $versionCommand ."';"); + foreach (self::RUNNER_VERSION_COMMAND as $langid => $versionCommand) { + $this->addSql( + "UPDATE language SET runner_version_command = NULL WHERE langid = :langid AND runner_version_command = :compiler_version_command" + ['compiler_version_command' => $versionCommand, 'langid' => $langid] + ); } }