2014-11-07 18:48:15 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$table = new PhrictionDocument();
|
|
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Populating Phriction mailkeys.')."\n";
|
2014-11-07 18:48:15 +01:00
|
|
|
|
|
|
|
foreach (new LiskMigrationIterator($table) as $doc) {
|
|
|
|
$id = $doc->getID();
|
|
|
|
|
|
|
|
$key = $doc->getMailKey();
|
|
|
|
if ((strlen($key) == 20) && (strpos($key, "\0") === false)) {
|
|
|
|
// To be valid, keys must have length 20 and not contain any null bytes.
|
|
|
|
// See T6487.
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Document has valid mailkey.')."\n";
|
2014-11-07 18:48:15 +01:00
|
|
|
continue;
|
|
|
|
} else {
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Populating mailkey for document %d...', $id)."\n";
|
2014-11-07 18:48:15 +01:00
|
|
|
$mail_key = Filesystem::readRandomCharacters(20);
|
|
|
|
queryfx(
|
|
|
|
$conn_w,
|
|
|
|
'UPDATE %T SET mailKey = %s WHERE id = %d',
|
|
|
|
$table->getTableName(),
|
|
|
|
$mail_key,
|
|
|
|
$id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Done.')."\n";
|