summaryrefslogtreecommitdiff
path: root/scripts/triminboxes.php
diff options
context:
space:
mode:
authorJeffery To <jeffery.to@gmail.com>2009-06-24 01:18:35 +0800
committerJeffery To <jeffery.to@gmail.com>2009-06-24 01:18:35 +0800
commit65f784120b45dc187e28313fa2c2dca2c976c150 (patch)
treecf1cb3e34483466d4f4a312c528579292e7603fc /scripts/triminboxes.php
parentf7d488d4b2bfdc8dfa6b5a2bc2931dbf824509a0 (diff)
parenteb40fbc17ad1efb0a4c51ee00b1e9408d2af382f (diff)
Merge branch '0.8.x' into notice-search-no-results
Diffstat (limited to 'scripts/triminboxes.php')
-rw-r--r--scripts/triminboxes.php43
1 files changed, 27 insertions, 16 deletions
diff --git a/scripts/triminboxes.php b/scripts/triminboxes.php
index 0d2eaeaf0..b2135d682 100644
--- a/scripts/triminboxes.php
+++ b/scripts/triminboxes.php
@@ -18,26 +18,37 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-# Abort if called from a web server
-if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
- print "This script must be run from the command line\n";
- exit(1);
-}
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-ini_set("max_execution_time", "0");
-ini_set("max_input_time", "0");
-set_time_limit(0);
-mb_internal_encoding('UTF-8');
+$shortoptions = 'u::';
+$longoptions = array('start-user-id::');
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
+$helptext = <<<END_OF_TRIM_HELP
+Batch script for trimming notice inboxes to a reasonable size.
+
+ -u <id>
+ --start-user-id=<id> User ID to start after. Default is all.
-require_once(INSTALLDIR . '/lib/common.php');
+END_OF_TRIM_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+$id = null;
+
+if (have_option('u')) {
+ $id = get_option_value('u');
+} else if (have_option('--start-user-id')) {
+ $id = get_option_value('--start-user-id');
+} else {
+ $id = null;
+}
$user = new User();
-if ($argc > 1) {
- $user->whereAdd('id > ' . $argv[1]);
+
+if (!empty($id)) {
+ $user->whereAdd('id > ' . $id);
}
+
$cnt = $user->find();
while ($user->fetch()) {
@@ -74,10 +85,10 @@ while ($user->fetch()) {
$delay = 3.0 * ($finish - $start);
print "Delaying $delay seconds...";
-
+
// Wait to let slaves catch up
usleep($delay * 1000000);
-
+
print "DONE.\n";
}