Fixed bug causing magic word MAG_NOEDITSECTION to be visible in plain text if user...
[mediawiki.git] / maintenance / compressOld.inc
blob22317c64975fac6e3cbf01aeac160c9461c1321d
1 <?php
3 include_once( "Article.php" );
5 function compressOldPages( $start = 0 ) {
6         $chunksize = 50;
7         print "Starting from old_id $start...\n";
8         do {
9                 $sql = "SELECT old_id,old_flags,old_namespace,old_title,old_text FROM old WHERE old_id>=$start ORDER BY old_id LIMIT $chunksize";
10                 $res = wfQuery( $sql, DB_READ, "compressOldPages" );
11                 if( wfNumRows( $res ) == 0 ) {
12                         break;
13                 }
14                 while( $row = wfFetchObject( $res ) ) {
15                         # print "  {$row->old_id} - {$row->old_namespace}:{$row->old_title}\n";
16                         compressPage( $row );
17                 }
18                 wfFreeResult( $res );
19                 $start += $chunksize;
20                 print "$start...\n";
21         } while( true );
24 function compressPage( $row ) {
25         if( false !== strpos( $row->old_flags, "gzip" ) ) {
26                 print "Already compressed row {$row->old_id}?\n";
27                 return false;
28         }
29         $flags = $row->old_flags ? "{$row->old_flags},gzip" : "gzip";
30         $compress = wfStrencode( gzdeflate( $row->old_text ) );
31         
32         $sql = "UPDATE old SET old_flags='$flags', old_text='$compress' WHERE old_id={$row->old_id} LIMIT 1";
33          $res = wfQuery( $sql, DB_WRITE, 'compressPage' );
34         return $res;