From 1a997fb0df2654c3ea662061914750ea1ad6636d Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Fri, 9 Jan 2015 13:58:11 -0800 Subject: [PATCH] Config - fix management scripts with --database parameter Summary: Fixes T6923. Turns out we can't use the editor since we don't have a user with a phid (just some omnipotent guy). Test Plan: ./bin/config set --database syntax.filemap '{}'; ./bin/config delete --database syntax.filemap Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6923 Differential Revision: https://secure.phabricator.com/D11301 --- .../PhabricatorConfigManagementDeleteWorkflow.php | 12 +++--------- .../PhabricatorConfigManagementMigrateWorkflow.php | 8 +++----- .../PhabricatorConfigManagementSetWorkflow.php | 9 +++------ .../config/storage/PhabricatorConfigEntry.php | 3 ++- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/applications/config/management/PhabricatorConfigManagementDeleteWorkflow.php b/src/applications/config/management/PhabricatorConfigManagementDeleteWorkflow.php index d89d4b7eb3..8f8cea0838 100644 --- a/src/applications/config/management/PhabricatorConfigManagementDeleteWorkflow.php +++ b/src/applications/config/management/PhabricatorConfigManagementDeleteWorkflow.php @@ -56,15 +56,9 @@ final class PhabricatorConfigManagementDeleteWorkflow } if ($use_database) { - $config_entry = id(new PhabricatorConfigOption()) - ->loadOneWhere( - 'namespace = %s and key = %s', - 'default', - $key); - PhabricatorConfigEditor::deleteConfig( - $this->getViewer(), - $config_entry, - PhabricatorContentSource::newConsoleSource()); + $config_entry = PhabricatorConfigEntry::loadConfigEntry($key); + $config_entry->setIsDeleted(1); + $config_entry->save(); } else { $config->deleteKeys(array($key)); } diff --git a/src/applications/config/management/PhabricatorConfigManagementMigrateWorkflow.php b/src/applications/config/management/PhabricatorConfigManagementMigrateWorkflow.php index 4b3caa09ce..1f992d003a 100644 --- a/src/applications/config/management/PhabricatorConfigManagementMigrateWorkflow.php +++ b/src/applications/config/management/PhabricatorConfigManagementMigrateWorkflow.php @@ -55,11 +55,9 @@ final class PhabricatorConfigManagementMigrateWorkflow 'Skipping option "%s"; already in database config.', $key)."\n"); continue; } else { - PhabricatorConfigEditor::storeNewValue( - $this->getViewer(), - id(new PhabricatorConfigEntry()) - ->loadOneWhere('namespace = %s AND key = %s', 'default', $key), - PhabricatorContentSource::newConsoleSource()); + $config_entry = PhabricatorConfigEntry::loadConfigEntry($key); + $config_entry->setValue($value); + $config_entry->save(); $key_count++; $console->writeOut(pht( 'Migrated option "%s" from file to database config.', $key)."\n"); diff --git a/src/applications/config/management/PhabricatorConfigManagementSetWorkflow.php b/src/applications/config/management/PhabricatorConfigManagementSetWorkflow.php index 5c4fc2765c..b20c91cbff 100644 --- a/src/applications/config/management/PhabricatorConfigManagementSetWorkflow.php +++ b/src/applications/config/management/PhabricatorConfigManagementSetWorkflow.php @@ -111,12 +111,9 @@ final class PhabricatorConfigManagementSetWorkflow if ($use_database) { $config_type = 'database'; - PhabricatorConfigEditor::storeNewValue( - $this->getViewer(), - id(new PhabricatorConfigEntry()) - ->loadOneWhere('namespace = %s AND key = %s', 'default', $key), - $value, - PhabricatorContentSource::newConsoleSource()); + $config_entry = PhabricatorConfigEntry::loadConfigEntry($key); + $config_entry->setValue($value); + $config_entry->save(); } else { $config_type = 'local'; id(new PhabricatorConfigLocalSource()) diff --git a/src/applications/config/storage/PhabricatorConfigEntry.php b/src/applications/config/storage/PhabricatorConfigEntry.php index 54fac1e333..abe7f4e036 100644 --- a/src/applications/config/storage/PhabricatorConfigEntry.php +++ b/src/applications/config/storage/PhabricatorConfigEntry.php @@ -46,7 +46,8 @@ final class PhabricatorConfigEntry if (!$config_entry) { $config_entry = id(new PhabricatorConfigEntry()) ->setConfigKey($key) - ->setNamespace('default'); + ->setNamespace('default') + ->setIsDeleted(0); } return $config_entry;