3 include_once( "Article.php" );
5 function compressOldPages( $start = 0 ) {
7 print "Starting from old_id $start...\n";
9 $end = $start + $chunksize;
10 $sql = "SELECT old_id,old_flags,old_namespace,old_title,old_text FROM old WHERE old_id>=$start ORDER BY old_id LIMIT $chunksize";
11 $res = wfQuery( $sql, DB_READ, "compressOldPages" );
12 if( wfNumRows( $res ) == 0 ) {
16 while( $row = wfFetchObject( $res ) ) {
17 # print " {$row->old_id} - {$row->old_namespace}:{$row->old_title}\n";
22 $start = $last + 1; # Deletion may leave long empty stretches
27 function compressPage( $row ) {
28 if( false !== strpos( $row->old_flags, "gzip" ) ) {
29 print "Already compressed row {$row->old_id}?\n";
32 $flags = $row->old_flags ? "{$row->old_flags},gzip" : "gzip";
33 $compress = wfStrencode( gzdeflate( $row->old_text ) );
35 $sql = "UPDATE old SET old_flags='$flags', old_text='$compress' WHERE old_id={$row->old_id} LIMIT 1";
36 $res = wfQuery( $sql, DB_WRITE, 'compressPage' );