Part two of allowing Special:Export to work on very long page histories...
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 20 Aug 2008 01:40:35 +0000 (01:40 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 20 Aug 2008 01:40:35 +0000 (01:40 +0000)
Part 1 was disabling the output buffers, allowing us to stream output continuously.

Part 2, here, is to use an unbuffered query to load the page/revision data, as we do for the command-line scripts. (This is done in what Tim assures me is a portable, database-neutral way, unlike all the maint scripts which still use old hacks.) This lets us actually stream the *input* -- otherwise streaming the output is darn useless!

Part 3 will be fixing up things like the max execution time. :)

includes/specials/SpecialExport.php

index b17140d..a8ba2be 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-# Copyright (C) 2003 Brion Vibber <brion@pobox.com>
+# Copyright (C) 2003-2008 Brion Vibber <brion@pobox.com>
 # http://www.mediawiki.org/
 #
 # This program is free software; you can redistribute it and/or modify
@@ -223,8 +223,18 @@ function wfSpecialExport( $page = '' ) {
 
                /* Ok, let's get to it... */
 
-               $db = wfGetDB( DB_SLAVE );
-               $exporter = new WikiExporter( $db, $history );
+               if( $history == WikiExporter::CURRENT ) {
+                       $lb = false;
+                       $db = wfGetDB( DB_SLAVE );
+                       $buffer = WikiExporter::BUFFER;
+               } else {
+                       // Use an unbuffered query; histories may be very long!
+                       $lb = wfGetLBFactory()->newMainLB();
+                       $db = $lb->getConnection( DB_LAST );
+                       $buffer = WikiExporter::STREAM;
+               }
+
+               $exporter = new WikiExporter( $db, $history, $buffer );
                $exporter->list_authors = $list_authors ;
                $exporter->openStream();
 
@@ -251,6 +261,9 @@ function wfSpecialExport( $page = '' ) {
                }
 
                $exporter->closeStream();
+               if( $lb ) {
+                       $lb->closeAll();
+               }
                return;
        }