aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-07-15 17:11:43 -0700
committerfriendica <info@friendica.com>2014-07-15 17:11:43 -0700
commit0435a08f3bafe47e0fe0cda6e698f93a5fab26e6 (patch)
tree7d39f888bedd8ad44ddcac0d9f6c5e5affff3725
parent01491e7d61576235f364af04039c9219ef6f6456 (diff)
downloadvolse-hubzilla-0435a08f3bafe47e0fe0cda6e698f93a5fab26e6.tar.gz
volse-hubzilla-0435a08f3bafe47e0fe0cda6e698f93a5fab26e6.tar.bz2
volse-hubzilla-0435a08f3bafe47e0fe0cda6e698f93a5fab26e6.zip
fix rename_system_url() for the case of somebody who has no local xchan_url (was cloned from elsewhere and is not primary)
-rwxr-xr-xboot.php32
-rw-r--r--version.inc2
2 files changed, 22 insertions, 12 deletions
diff --git a/boot.php b/boot.php
index e6bbbee2f..7552ddb92 100755
--- a/boot.php
+++ b/boot.php
@@ -1365,12 +1365,21 @@ function fix_system_urls($oldurl,$newurl) {
// that they can clean up their hubloc tables (this includes directories).
// It's a very expensive operation so you don't want to have to do it often or after your site gets to be large.
- $r = q("select xchan.*, channel.* from xchan left join channel on channel_hash = xchan_hash where xchan_url like '%s'",
+ $r = q("select xchan.*, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_url like '%s'",
dbesc($oldurl . '%')
);
+
if($r) {
foreach($r as $rr) {
- $channel = substr($rr['xchan_addr'],0,strpos($rr['xchan_addr'],'@'));
+ $channel_address = substr($rr['hubloc_addr'],0,strpos($rr['hubloc_addr'],'@'));
+
+ // get the associated channel. If we don't have a local channel, do nothing for this entry.
+
+ $c = q("select * from channel where channel_hash = '%s' limit 1",
+ dbesc($rr['hubloc_hash'])
+ );
+ if(! $c)
+ continue;
$parsed = @parse_url($newurl);
if(! $parsed)
@@ -1387,9 +1396,13 @@ function fix_system_urls($oldurl,$newurl) {
// paths aren't going to work. You have to be at the (sub)domain root
// . (($parsed['path']) ? $parsed['path'] : '');
+ // The xchan_url might point to another nomadic identity clone
+
+ $replace_xchan_url = ((strpos($rr['xchan_url'],$oldurl) !== false) ? true : false);
+
$x = q("update xchan set xchan_addr = '%s', xchan_url = '%s', xchan_connurl = '%s', xchan_follow = '%s', xchan_connpage = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_date = '%s' where xchan_hash = '%s' limit 1",
- dbesc($channel . '@' . $rhs),
- dbesc(str_replace($oldurl,$newurl,$rr['xchan_url'])),
+ dbesc($channel_address . '@' . $rhs),
+ dbesc(($replace_xchan_url) ? str_replace($oldurl,$newurl,$rr['xchan_url']) : $rr['xchan_url']),
dbesc(str_replace($oldurl,$newurl,$rr['xchan_connurl'])),
dbesc(str_replace($oldurl,$newurl,$rr['xchan_follow'])),
dbesc(str_replace($oldurl,$newurl,$rr['xchan_connpage'])),
@@ -1400,26 +1413,23 @@ function fix_system_urls($oldurl,$newurl) {
dbesc($rr['xchan_hash'])
);
-
$y = q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_url_sig = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s' limit 1",
- dbesc($channel . '@' . $rhs),
+ dbesc($channel_address . '@' . $rhs),
dbesc($newurl),
- dbesc(base64url_encode(rsa_sign($newurl,$rr['channel_prvkey']))),
+ dbesc(base64url_encode(rsa_sign($newurl,$c[0]['channel_prvkey']))),
dbesc($newhost),
dbesc($newurl . '/post'),
dbesc($rr['xchan_hash']),
dbesc($oldurl)
);
-
$z = q("update profile set photo = '%s', thumb = '%s' where uid = %d",
dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_l'])),
dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_m'])),
- intval($rr['channel_id'])
+ intval($c[0]['channel_id'])
);
- proc_run('php', 'include/notifier.php', 'refresh_all', $rr['channel_id']);
-
+ proc_run('php', 'include/notifier.php', 'refresh_all', $c[0]['channel_id']);
}
}
}
diff --git a/version.inc b/version.inc
index 053356f75..bf817a3db 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2014-07-14.736
+2014-07-15.737