aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-06-08 22:41:21 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-06-08 22:41:21 +0000
commit740d6a543605e6179b77c996aae3030b96069c5e (patch)
treee1a02bc062f596ab3a9242153f67f9f6bf959344
parent0254a2d9200ac30e7430efc1dce6005aa75ffa72 (diff)
downloadelgg-740d6a543605e6179b77c996aae3030b96069c5e.tar.gz
elgg-740d6a543605e6179b77c996aae3030b96069c5e.tar.bz2
Refs #3510, #3416. Merged update for making sure users have relationship member_of on site object.
git-svn-id: http://code.elgg.org/elgg/trunk@9144 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/upgrades/2011052801.php45
-rw-r--r--version.php2
2 files changed, 46 insertions, 1 deletions
diff --git a/engine/lib/upgrades/2011052801.php b/engine/lib/upgrades/2011052801.php
new file mode 100644
index 000000000..8084bc06c
--- /dev/null
+++ b/engine/lib/upgrades/2011052801.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Make sure all users have the relationship member_of_site
+ */
+global $DB_QUERY_CACHE, $DB_PROFILE, $ENTITY_CACHE, $CONFIG;
+$db_prefix = get_config('dbprefix');
+
+$limit = 100;
+
+$q = "SELECT e.* FROM {$db_prefix}entities e
+ WHERE e.type = 'user' AND e.guid NOT IN (
+ SELECT guid_one FROM {$db_prefix}entity_relationships
+ WHERE guid_two = 1 AND relationship = 'member_of_site'
+ )
+ LIMIT $limit";
+
+$users = get_data($q);
+
+while ($users) {
+ $DB_QUERY_CACHE = $DB_PROFILE = $ENTITY_CACHE = array();
+
+ // do manually to not trigger any events because these aren't new users.
+ foreach ($users as $user) {
+ $rel_q = "INSERT INTO {$db_prefix}entity_relationships VALUES (
+ '',
+ '$user->guid',
+ 'member_of_site',
+ '$user->site_guid',
+ '$user->time_created'
+ )";
+
+ insert_data($rel_q);
+ }
+
+ // every time we run this query we've just reduced the rows it returns by $limit
+ // so don't pass an offset.
+ $q = "SELECT e.* FROM {$db_prefix}entities e
+ WHERE e.type = 'user' AND e.guid NOT IN (
+ SELECT guid_one FROM {$db_prefix}entity_relationships
+ WHERE guid_two = 1 AND relationship = 'member_of_site'
+ )
+ LIMIT $limit";
+
+ $users = get_data($q);
+} \ No newline at end of file
diff --git a/version.php b/version.php
index f3e7010b0..d1cc63aef 100644
--- a/version.php
+++ b/version.php
@@ -11,7 +11,7 @@
// YYYYMMDD = Elgg Date
// XX = Interim incrementer
-$version = 2011032200;
+$version = 2011052801;
// Human-friendly version name
$release = '1.8b1';