mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
ab86523ac4
Summary: Fixes T10410. Immediate impact of this is that you can now actually delete properties from Almanac services, devices and bindings. The meat of the change is switching from CustomField to EditEngine for most of the actual editing logic. CustomField creates a lot of problems with using EditEngine for everything else (D15326), and weird, hard-to-resolve bugs like this one (not being able to delete stuff). Using EditEngine to do this stuff instead seems like it works out much better -- I did this in ProfilePanel first and am happy with how it looks. This also makes the internal storage for properties JSON instead of raw text. Test Plan: - Created, edited and deleted properties on services, devices and bindings. - Edited and reset builtin properties on repository services. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10410 Differential Revision: https://secure.phabricator.com/D15327
28 lines
695 B
PHP
28 lines
695 B
PHP
<?php
|
|
|
|
$table = new AlmanacProperty();
|
|
$conn_w = $table->establishConnection('w');
|
|
|
|
// We're going to JSON-encode the value in each row: previously rows stored
|
|
// plain strings, but now they store JSON, so we need to update them.
|
|
|
|
foreach (new LiskMigrationIterator($table) as $property) {
|
|
$key = $property->getFieldName();
|
|
|
|
$current_row = queryfx_one(
|
|
$conn_w,
|
|
'SELECT fieldValue FROM %T WHERE id = %d',
|
|
$table->getTableName(),
|
|
$property->getID());
|
|
|
|
if (!$current_row) {
|
|
continue;
|
|
}
|
|
|
|
queryfx(
|
|
$conn_w,
|
|
'UPDATE %T SET fieldValue = %s WHERE id = %d',
|
|
$table->getTableName(),
|
|
phutil_json_encode($current_row['fieldValue']),
|
|
$property->getID());
|
|
}
|