Merge pull request #3763 from annando/relocation-addr

Fixes the not changed "addr" entry when an account is imported
This commit is contained in:
Tobias Diekershoff 2017-10-07 06:01:16 +00:00 committed by GitHub
commit cc9074bed5

View File

@ -125,6 +125,10 @@ function import_account(App $a, $file) {
$oldbaseurl = $account['baseurl'];
$newbaseurl = System::baseUrl();
$oldaddr = str_replace('http://', '@', normalise_link($oldbaseurl));
$newaddr = str_replace('http://', '@', normalise_link($newbaseurl));
$olduid = $account['user']['uid'];
unset($account['user']['uid']);
@ -133,7 +137,7 @@ function import_account(App $a, $file) {
unset($account['user']['expire_notification_sent']);
foreach ($account['user'] as $k => &$v) {
$v = str_replace($oldbaseurl, $newbaseurl, $v);
$v = str_replace(array($oldbaseurl, $oldaddr), array($newbaseurl, $newaddr), $v);
}
// import user
@ -153,7 +157,7 @@ function import_account(App $a, $file) {
foreach ($account['profile'] as &$profile) {
foreach ($profile as $k => &$v) {
$v = str_replace($oldbaseurl, $newbaseurl, $v);
$v = str_replace(array($oldbaseurl, $oldaddr), array($newbaseurl, $newaddr), $v);
foreach (array("profile", "avatar") as $k) {
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
}
@ -172,7 +176,7 @@ function import_account(App $a, $file) {
foreach ($account['contact'] as &$contact) {
if ($contact['uid'] == $olduid && $contact['self'] == '1') {
foreach ($contact as $k => &$v) {
$v = str_replace($oldbaseurl, $newbaseurl, $v);
$v = str_replace(array($oldbaseurl, $oldaddr), array($newbaseurl, $newaddr), $v);
foreach (array("profile", "avatar", "micro") as $k) {
$v = str_replace($oldbaseurl . "/photo/" . $k . "/" . $olduid . ".jpg", $newbaseurl . "/photo/" . $k . "/" . $newuid . ".jpg", $v);
}