Skip to content

Commit 0399f44

Browse files
authored
Merge pull request #331 from OpenConext/bugfix/escape-vetting-type-migration-parameters
Prepared statement for vetting_type migration
2 parents 10d89af + 0264dd7 commit 0399f44

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/Surfnet/Migrations/Version20210610131957.php

+15-10
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ final class Version20210610131957 extends AbstractMigration
2525

2626
private static $update = <<<SQL
2727
UPDATE event_stream
28-
SET payload = '%s'
29-
WHERE uuid = '%s'
30-
AND playhead = %s;
28+
SET payload = :payload
29+
WHERE uuid = :uuid
30+
AND playhead = :playhead;
3131
SQL;
3232

3333
public function up(Schema $schema) : void
@@ -36,23 +36,28 @@ public function up(Schema $schema) : void
3636
$this->addSql('# Updating entities.');
3737

3838
$affectedEventStreamRows = $this->connection->executeQuery(self::$select);
39+
40+
$this->write("<info>Affected records: {$affectedEventStreamRows->rowCount()}</info>");
41+
3942
if ($affectedEventStreamRows->rowCount() === 0) {
4043
return;
4144
}
45+
4246
foreach ($affectedEventStreamRows as $eventStream) {
4347
$rawPayload = $eventStream['payload'];
4448
$uuid = $eventStream['uuid'];
4549
$playhead = $eventStream['playhead'];
4650

47-
$payload = $this->stripSensitiveData($rawPayload);
51+
$this->write("<info>Migating: {$uuid}#{$playhead}</info>");
4852

53+
$payload = $this->stripSensitiveData($rawPayload);
4954
$this->connection->executeUpdate(
50-
sprintf(
51-
self::$update,
52-
$payload,
53-
$uuid,
54-
$playhead
55-
)
55+
self::$update,
56+
[
57+
'payload' => $payload,
58+
'uuid' => $uuid,
59+
'playhead' => $playhead,
60+
]
5661
);
5762
}
5863
}

0 commit comments

Comments
 (0)