From c33a7b4847a5d1537dcc7272dc056bc64f3f1cb3 Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 4 Jun 2010 15:41:31 +0000 Subject: Merged r6349:6351 from 1.7 to trunk. git-svn-id: http://code.elgg.org/elgg/trunk@6357 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/upgrades/2010060401.php | 57 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 engine/lib/upgrades/2010060401.php (limited to 'engine/lib/upgrades/2010060401.php') diff --git a/engine/lib/upgrades/2010060401.php b/engine/lib/upgrades/2010060401.php new file mode 100644 index 000000000..2106bdbc0 --- /dev/null +++ b/engine/lib/upgrades/2010060401.php @@ -0,0 +1,57 @@ +dbprefix}users_entity"); +while ($user = mysql_fetch_object($user_guids)) { + + $query = "SELECT * FROM {$CONFIG->dbprefix}entity_relationships WHERE guid_one=$user->guid AND relationship LIKE 'notify%'"; + $relationships = mysql_query($query); + if (mysql_num_rows($relationships) == 0) { + // no notify relationships for this user + continue; + } + + while ($obj = mysql_fetch_object($relationships)) { + $query = "SELECT type FROM {$CONFIG->dbprefix}entities WHERE guid=$obj->guid_two"; + $results = mysql_query($query); + if (mysql_num_rows($results) == 0) { + // entity doesn't exist - shouldn't be possible + continue; + } + + $entity = mysql_fetch_object($results); + + switch ($entity->type) { + case 'user': + $relationship_type = 'friend'; + break; + case 'group': + $relationship_type = 'member'; + break; + } + + if (isset($relationship_type)) { + $query = "SELECT * FROM {$CONFIG->dbprefix}entity_relationships + WHERE guid_one=$user->guid AND relationship='$relationship_type' + AND guid_two=$obj->guid_two"; + $results = mysql_query($query); + if (mysql_num_rows($results) == 0) { + $query = "DELETE FROM {$CONFIG->dbprefix}entity_relationships WHERE id=$obj->id"; + mysql_query($query); + $count++; + } + } + } + +} + +if (is_callable('error_log')) { + error_log("Deleted $count notify relationships in upgrade"); +} -- cgit v1.2.3