3 function compressOldPages( $start = 0 ) {
5 print "Starting from old_id $start...\n";
7 $end = $start + $chunksize;
8 $sql = "SELECT old_id,old_flags,old_namespace,old_title,old_text FROM old WHERE old_id>=$start ORDER BY old_id LIMIT $chunksize";
9 $res = wfQuery( $sql, DB_READ, "compressOldPages" );
10 if( wfNumRows( $res ) == 0 ) {
14 while( $row = wfFetchObject( $res ) ) {
15 # print " {$row->old_id} - {$row->old_namespace}:{$row->old_title}\n";
20 $start = $last + 1; # Deletion may leave long empty stretches
25 function compressPage( $row ) {
26 if( false !== strpos( $row->old_flags, "gzip" ) ) {
27 print "Already compressed row {$row->old_id}?\n";
30 $flags = $row->old_flags ? "{$row->old_flags},gzip" : "gzip";
31 $compress = wfStrencode( gzdeflate( $row->old_text ) );
33 $sql = "UPDATE old SET old_flags='$flags', old_text='$compress' WHERE old_id={$row->old_id} LIMIT 1";
34 $res = wfQuery( $sql, DB_WRITE, 'compressPage' );