mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
3b1294cf45
Summary: Ref T13077. We need to know the maximum version of a document in several cases, so denormalize it onto the Document object. Then clean up some behaviors where we edit a document with, e.g., 7 versions but version 5 is currently published. For now, we: edit starting with version 7, save as version 8, and immediately publish the new version. Test Plan: - Ran migration. - Edited a draft page without hitting any weird version errors. - Checked database for sensible `maxVersion` values. Reviewers: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13077 Differential Revision: https://secure.phabricator.com/D19625
30 lines
701 B
PHP
30 lines
701 B
PHP
<?php
|
|
|
|
// Populate the "maxVersion" column by copying the maximum "version" from the
|
|
// content table.
|
|
|
|
$document_table = new PhrictionDocument();
|
|
$content_table = new PhrictionContent();
|
|
|
|
$conn = $document_table->establishConnection('w');
|
|
|
|
$iterator = new LiskRawMigrationIterator(
|
|
$conn,
|
|
$document_table->getTableName());
|
|
foreach ($iterator as $row) {
|
|
$content = queryfx_one(
|
|
$conn,
|
|
'SELECT MAX(version) max FROM %T WHERE documentPHID = %s',
|
|
$content_table->getTableName(),
|
|
$row['phid']);
|
|
if (!$content) {
|
|
continue;
|
|
}
|
|
|
|
queryfx(
|
|
$conn,
|
|
'UPDATE %T SET maxVersion = %d WHERE id = %d',
|
|
$document_table->getTableName(),
|
|
$content['max'],
|
|
$row['id']);
|
|
}
|