]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/strip_geo.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / scripts / strip_geo.php
index 010fb31f5484548ad25433f39d0b6b7ab6e94e98..165736816d8396c8d4d96bfb6cad1709d6a0cc63 100755 (executable)
@@ -21,7 +21,7 @@
 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
 
 $shortoptions = 'i::n::y';
-$longoptions = array('id=', 'nickname=', 'yes', 'dry-run');
+$longoptions = array('id=', 'nickname=', 'yes', 'dry-run', 'all');
 
 $helptext = <<<END_OF_HELP
 strip_geo.php [options]
@@ -31,21 +31,23 @@ Removes geolocation info from the given user's notices.
   -n --nickname nickname of the user
   -y --yes      do not wait for confirmation
      --dry-run  list affected notices without deleting
+     --all      run over and decache all messages, even if they don't
+                have geo data now (helps to fix cache bugs)
 
 END_OF_HELP;
 
-require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR.'/scripts/commandline.inc.php';
 
 if (have_option('i', 'id')) {
     $id = get_option_value('i', 'id');
-    $profile = Profile::staticGet('id', $id);
+    $profile = Profile::getKV('id', $id);
     if (empty($profile)) {
         print "Can't find local or remote profile with ID $id\n";
         exit(1);
     }
 } else if (have_option('n', 'nickname')) {
     $nickname = get_option_value('n', 'nickname');
-    $user = User::staticGet('nickname', $nickname);
+    $user = User::getKV('nickname', $nickname);
     if (empty($user)) {
         print "Can't find local user with nickname '$nickname'\n";
         exit(1);
@@ -67,10 +69,14 @@ if (!have_option('y', 'yes') && !have_option('--dry-run')) {
 }
 
 // @fixme for a very prolific poster this could be too many.
-print "Finding notices with geolocation data...";
 $notice = new Notice();
 $notice->profile_id = $profile->id;
-$notice->whereAdd("lat != ''");
+if (have_option('--all')) {
+    print "Finding all notices by $profile->nickname...";
+} else {
+    print "Finding notices by $profile->nickname with geolocation data...";
+    $notice->whereAdd("lat != ''");
+}
 $notice->find();
 
 if ($notice->N) {
@@ -101,10 +107,10 @@ if ($notice->N) {
             $ok = $update->query($query);
             if ($ok) {
                 // And now we decache him manually, as query() doesn't know what we're doing...
-                $orig->blow();
+                $orig->decache();
                 echo "(removed)";
             } else {
-                echo "(failed?)";
+                echo "(unchanged?)";
             }
         }
         print "\n";