From dacd0f3e6df020eda81d60139ac88437fed3352e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 17 Mar 2010 12:14:19 -0700 Subject: Fix to regression for auto-subscribe - was backwards. --- classes/Subscription.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/Subscription.php b/classes/Subscription.php index 9cef2df1a..5ac95f922 100644 --- a/classes/Subscription.php +++ b/classes/Subscription.php @@ -105,8 +105,8 @@ class Subscription extends Memcached_DataObject $auto = new Subscription(); - $auto->subscriber = $subscriber->id; - $auto->subscribed = $other->id; + $auto->subscriber = $other->id; + $auto->subscribed = $subscriber->id; $auto->created = common_sql_now(); $result = $auto->insert(); -- cgit v1.2.3-54-g00ecf From 425ddcaa265f5b305176ca0bcd48833a0ef0c75a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 18 Mar 2010 08:35:10 -0500 Subject: add exception on inconsistent db to User::getProfile() --- classes/User.php | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'classes') diff --git a/classes/User.php b/classes/User.php index 330da039b..13f63010f 100644 --- a/classes/User.php +++ b/classes/User.php @@ -75,7 +75,11 @@ class User extends Memcached_DataObject function getProfile() { - return Profile::staticGet('id', $this->id); + $profile = Profile::staticGet('id', $this->id); + if (empty($profile)) { + throw new UserNoProfileException($this); + } + return $profile; } function isSubscribed($other) @@ -140,9 +144,6 @@ class User extends Memcached_DataObject function getCurrentNotice() { $profile = $this->getProfile(); - if (!$profile) { - return null; - } return $profile->getCurrentNotice(); } @@ -469,21 +470,13 @@ class User extends Memcached_DataObject function getTaggedNotices($tag, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { $profile = $this->getProfile(); - if (!$profile) { - return null; - } else { - return $profile->getTaggedNotices($tag, $offset, $limit, $since_id, $before_id); - } + return $profile->getTaggedNotices($tag, $offset, $limit, $since_id, $before_id); } function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) { $profile = $this->getProfile(); - if (!$profile) { - return null; - } else { - return $profile->getNotices($offset, $limit, $since_id, $before_id); - } + return $profile->getNotices($offset, $limit, $since_id, $before_id); } function favoriteNotices($offset=0, $limit=NOTICES_PER_PAGE, $own=false) @@ -624,14 +617,12 @@ class User extends Memcached_DataObject function getSubscriptions($offset=0, $limit=null) { $profile = $this->getProfile(); - assert(!empty($profile)); return $profile->getSubscriptions($offset, $limit); } function getSubscribers($offset=0, $limit=null) { $profile = $this->getProfile(); - assert(!empty($profile)); return $profile->getSubscribers($offset, $limit); } @@ -695,9 +686,7 @@ class User extends Memcached_DataObject function delete() { $profile = $this->getProfile(); - if ($profile) { - $profile->delete(); - } + $profile->delete(); $related = array('Fave', 'Confirm_address', -- cgit v1.2.3-54-g00ecf From 515cdf28a83eda5cc82f0c423099a36c0168dbb6 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 18 Mar 2010 09:22:08 -0700 Subject: Ensure that DB connection is active at start of User::updateKeys() and Foreign_user::updateKeys(); calls to $this->_quote() require a live connection object and don't lazy-initialize themselves. May fix WSOD when changing incoming email address. --- classes/Foreign_user.php | 1 + classes/User.php | 1 + 2 files changed, 2 insertions(+) (limited to 'classes') diff --git a/classes/Foreign_user.php b/classes/Foreign_user.php index 8b3e03dfb..0dd94ffb9 100644 --- a/classes/Foreign_user.php +++ b/classes/Foreign_user.php @@ -41,6 +41,7 @@ class Foreign_user extends Memcached_DataObject function updateKeys(&$orig) { + $this->_connect(); $parts = array(); foreach (array('id', 'service', 'uri', 'nickname') as $k) { if (strcmp($this->$k, $orig->$k) != 0) { diff --git a/classes/User.php b/classes/User.php index 13f63010f..0b25b71a0 100644 --- a/classes/User.php +++ b/classes/User.php @@ -91,6 +91,7 @@ class User extends Memcached_DataObject function updateKeys(&$orig) { + $this->_connect(); $parts = array(); foreach (array('nickname', 'email', 'jabber', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) { if (strcmp($this->$k, $orig->$k) != 0) { -- cgit v1.2.3-54-g00ecf