Skip to content

Commit

Permalink
Merged migration fixes from stable
Browse files Browse the repository at this point in the history
  • Loading branch information
moodler committed Jun 18, 2006
1 parent e5f121c commit fb06b25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
9 changes: 3 additions & 6 deletions admin/utfdbmigrate.php
Expand Up @@ -298,10 +298,7 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
$crash->field = $crashdata[1];
$crash->record = $crashdata[2];

print_heading('Resume information :');
echo '<br>Resuming from @ table : '.$crash->table;
echo '<br>Resuming from @ field : '.$crash->field;
echo '<br>Resuming from @ record : '.$crash->record;
notify("Resuming migration from: $crash->table / .$crash->field, Record: $crash->record");
}

/************************************************************************
Expand Down Expand Up @@ -499,7 +496,6 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
continue;
} else {
$crash = 0;
print_heading('recovering from '.$dbtablename.'--'.$fieldname.'--'.$record->id);
}
}

Expand Down Expand Up @@ -576,7 +572,8 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
$processedrecords++;
//print some output once in a while
if (($processedrecords) % 5000 == 0) {
echo 'Processing...'.$dbtablename.'...'.$fieldname.'...'.$record->id;
print_progress($done, $tablestoconvert, 5, 1,
'Processing: '.$dbtablename.'/'.$fieldname.' ');
}
}
}else {
Expand Down
17 changes: 8 additions & 9 deletions lib/adminlib.php
Expand Up @@ -310,8 +310,7 @@ function set_cron_lock($name,$value=true,$staleafter=7200,$clobberstale=false) {
return true;
}

function print_progress($done, $total, $updatetime=5, $sleeptime=1) {
static $count;
function print_progress($done, $total, $updatetime=5, $sleeptime=1, $donetext='') {
static $starttime;
static $lasttime;

Expand All @@ -327,12 +326,6 @@ function print_progress($done, $total, $updatetime=5, $sleeptime=1) {
echo '</div>';
}

if (!isset($count)) {
$count = 0;
}

$count++;

$now = time();

if ($done && (($now - $lasttime) >= $updatetime)) {
Expand All @@ -341,8 +334,14 @@ function print_progress($done, $total, $updatetime=5, $sleeptime=1) {
$percentage = format_float((float)$done / (float)$total, 2);
$width = (int)(500 * $percentage);

if ($projectedtime > 10) {
$projectedtext = ' Ending: '.format_time($projectedtime);
} else {
$projectedtext = '';
}

echo '<script>';
echo 'document.getElementById("text").innerHTML = "'.$count.' done. Ending: '.format_time($projectedtime).'";'."\n";
echo 'document.getElementById("text").innerHTML = "'.addslashes($donetext).' '.$done.' done.'.$projectedtext.'";'."\n";
echo 'document.getElementById("slider").style.width = \''.$width.'px\';'."\n";
echo '</script>';

Expand Down

0 comments on commit fb06b25

Please sign in to comment.