- server: make fix_venue.php work faster

svn path=/trunk/boinc/; revision=25712
This commit is contained in:
David Anderson 2012-05-25 20:39:37 +00:00
parent 2db88e20a8
commit e82d605554
3 changed files with 31 additions and 9 deletions

View File

@ -4011,3 +4011,12 @@ David 23 May 2012
configure.ac
lib/
network.h
David 23 May 2012
- server: make fix_venue.php work faster
html/
inc/
boinc_db.inc
ops/
fix_venue.php

View File

@ -120,6 +120,10 @@ class BoincUser {
$db = BoincDb::get();
return $db->count('user', $clause);
}
static function max($field) {
$db = BoincDb::get();
return $db->max('user', $field);
}
function update($clause) {
$db = BoincDb::get();
return $db->update($this, 'user', $clause);

View File

@ -1,7 +1,11 @@
<?php
// repair user.global_prefs fields that were corrupted
// (non-parsable XML) by a bug at some point
// (non-parsable XML) by a bug at some point.
//
// This fixes 2 types of corruption:
// - missing </venue> tag before closing </global_preferences>
// - \" instead of "
require_once("../inc/boinc_db.inc");
@ -9,6 +13,9 @@ require_once("../inc/boinc_db.inc");
// This fixes an XML error introduced at some point in the past
//
function repair_prefs($prefs) {
if (strstr($prefs, '\"')) {
return str_replace('\"', '"', $prefs);
}
$x = strstr($prefs, "</global_preferences>", true);
if (!$x) return null;
return "$x\n </venue>\n</global_preferences>\n";
@ -24,18 +31,18 @@ function process_set($users) {
if ($retval) {
//echo "$user->id: good\n";
} else {
echo "$user->id: prefs don't parse\n";
echo "repairing prefs for user $user->id\n";
$p = repair_prefs($user->global_prefs);
if ($p) {
$retval = @simplexml_load_string($p);
if ($retval) {
$user->update("global_prefs='$p'");
echo "repair succeeded for $user->id\n";
echo " repair succeeded\n";
} else {
echo "couldn't repair prefs for user $user->id\n";
echo " repair failed\n";
}
} else {
echo "bad prefs for user $user->id\n";
echo " prefs are missing end tag\n";
}
}
}
@ -43,11 +50,13 @@ function process_set($users) {
$n = 0;
while (1) {
$users = BoincUser::enum("true limit $n,1000");
echo "processing from $n\n";
$maxid = BoincUser::max("id");
while ($n <= $maxid) {
$m = $n + 1000;
$users = BoincUser::enum("id >= $n and id < $m");
//echo "processing from $n\n";
if (!$users) break;
process_set($users);
$n += sizeof($users);
$n = $m;
}
?>