Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91181439
PhabricatorConfigManagementMigrateWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 8, 17:36
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Nov 10, 17:36 (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
22214001
Attached To
rPH Phabricator
PhabricatorConfigManagementMigrateWorkflow.php
View Options
<?php
final
class
PhabricatorConfigManagementMigrateWorkflow
extends
PhabricatorConfigManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'migrate'
)
->
setExamples
(
'**migrate**'
)
->
setSynopsis
(
pht
(
'Migrate file-based configuration to more modern storage.'
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$console
=
PhutilConsole
::
getConsole
();
$key_count
=
0
;
$options
=
PhabricatorApplicationConfigOptions
::
loadAllOptions
();
$local_config
=
new
PhabricatorConfigLocalSource
();
$database_config
=
new
PhabricatorConfigDatabaseSource
(
'default'
);
$config_sources
=
PhabricatorEnv
::
getConfigSourceStack
()->
getStack
();
$console
->
writeOut
(
pht
(
'Migrating file-based config to more modern config...'
).
"
\n
"
);
foreach
(
$config_sources
as
$config_source
)
{
if
(!(
$config_source
instanceof
PhabricatorConfigFileSource
))
{
$console
->
writeOut
(
pht
(
'Skipping config of source type %s...'
,
get_class
(
$config_source
)).
"
\n
"
);
continue
;
}
$console
->
writeOut
(
pht
(
'Migrating file source...'
).
"
\n
"
);
$all_keys
=
$config_source
->
getAllKeys
();
foreach
(
$all_keys
as
$key
=>
$value
)
{
$option
=
idx
(
$options
,
$key
);
if
(!
$option
)
{
$console
->
writeOut
(
pht
(
'Skipping obsolete option: %s'
,
$key
).
"
\n
"
);
continue
;
}
$in_local
=
$local_config
->
getKeys
(
array
(
$option
->
getKey
()));
if
(
$in_local
)
{
$console
->
writeOut
(
pht
(
'Skipping option "%s"; already in local config.'
,
$key
).
"
\n
"
);
continue
;
}
$is_locked
=
$option
->
getLocked
();
if
(
$is_locked
)
{
$local_config
->
setKeys
(
array
(
$option
->
getKey
()
=>
$value
));
$key_count
++;
$console
->
writeOut
(
pht
(
'Migrated option "%s" from file to local config.'
,
$key
).
"
\n
"
);
}
else
{
$in_database
=
$database_config
->
getKeys
(
array
(
$option
->
getKey
()));
if
(
$in_database
)
{
$console
->
writeOut
(
pht
(
'Skipping option "%s"; already in database config.'
,
$key
).
"
\n
"
);
continue
;
}
else
{
PhabricatorConfigEditor
::
deleteConfig
(
$this
->
getViewer
(),
$option
,
PhabricatorContentSource
::
newFromConsole
());
$key_count
++;
$console
->
writeOut
(
pht
(
'Migrated option "%s" from file to local config.'
,
$key
).
"
\n
"
);
}
}
}
}
$console
->
writeOut
(
pht
(
'Done. Migrated %d keys.'
,
$key_count
).
"
\n
"
);
return
0
;
}
}
Event Timeline
Log In to Comment