summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-10-07 11:26:07 -0700
committerBrion Vibber <brion@pobox.com>2010-10-07 11:26:07 -0700
commit458f93bddd45ad3f37e18565edef67ac02ed15c2 (patch)
tree1c00323b5aae8d16fb2e7bd23e79fb476866d064 /plugins
parenta9654beb5d7506e7594fd88ce2739d993e27e982 (diff)
OStatus fixup-shadow.php: add check for user_group entries with 'uri' entry shadowing an actual local_group -- this can cause trouble now that we sometimes actually use the uri field for lookups, and leaving the entries around would break updating the table to fill out formerly missing uris, since the unique index entry would already be taken by the bad entry.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/OStatus/scripts/fixup-shadow.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/plugins/OStatus/scripts/fixup-shadow.php b/plugins/OStatus/scripts/fixup-shadow.php
index 3e2c18e02..18df2995f 100644
--- a/plugins/OStatus/scripts/fixup-shadow.php
+++ b/plugins/OStatus/scripts/fixup-shadow.php
@@ -84,6 +84,50 @@ while ($group->fetch()) {
}
echo "\n";
+// And there may be user_group entries remaining where we've already killed
+// the ostatus_profile. These were "harmless" until our lookup started actually
+// using the uri field, at which point we can clearly see it breaks stuff.
+echo "Checking for leftover bogus user_group.uri entries obscuring local_group entries...\n";
+
+$group = new User_group();
+$group->joinAdd(array('id', 'local_group:group_id'), 'LEFT');
+$group->whereAdd('group_id IS NULL');
+
+
+$marker = mt_rand(31337, 31337000);
+$groupTemplate = common_local_url('groupbyid', array('id' => $marker));
+$encGroup = $group->escape($groupTemplate, true);
+$encGroup = str_replace($marker, '%', $encGroup);
+echo " LIKE '$encGroup'\n";
+$group->whereAdd("uri LIKE '$encGroup'");
+
+$group->find();
+$count = $group->N;
+echo "Found $count...\n";
+
+while ($group->fetch()) {
+ $uri = $group->uri;
+ if (preg_match('!/group/(\d+)/id!', $uri, $matches)) {
+ $id = intval($matches[1]);
+ $local = Local_group::staticGet('group_id', $id);
+ if ($local) {
+ $nick = $local->nickname;
+ } else {
+ $nick = '<deleted>';
+ }
+ echo "local group $id ($local->nickname) hidden by $uri (bogus group id $group->id)";
+ if ($dry) {
+ echo " - skipping\n";
+ } else {
+ echo " - removing bogus user_group entry...";
+ $evil = User_group::staticGet('id', $group->id);
+ $evil->delete();
+ echo " ok\n";
+ }
+ }
+}
+echo "\n";
+
// Fallback?
echo "Checking for bogus profiles blocking local users/groups by URI pattern match...\n";