From 131c6981e508102fce97fce9507fd429b1723931 Mon Sep 17 00:00:00 2001
From: Cerdic <cedric@yterium.com>
Date: Mon, 12 Jun 2006 13:17:05 +0000
Subject: [PATCH] ob_flush pas toujours disponible

---
 ecrire/exec/export_all.php | 16 +++++++++++-----
 ecrire/inc/import.php      | 10 +++++++---
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/ecrire/exec/export_all.php b/ecrire/exec/export_all.php
index 21286d61ad..c3878aa9ab 100644
--- a/ecrire/exec/export_all.php
+++ b/ecrire/exec/export_all.php
@@ -52,6 +52,7 @@ if (!isset($EXPORT_tables_noexport)){
 		$EXPORT_tables_noexport[]='spip_auteurs_messages';
 	}
 }
+$GLOBALS['flag_ob_flush'] = function_exists('ob_flush');
 
 function exec_export_all_dist()
 {
@@ -190,7 +191,8 @@ function exec_export_all_dist()
 			array_unshift($tables_for_dump,$link_table);
 	}
 
-	ob_flush();flush();
+	if ($GLOBALS['flag_ob_flush']) ob_flush();
+	flush();
 
 	$status_dump = explode("::",$GLOBALS['meta']["status_dump"]);
 	$etape = $status_dump[2];
@@ -201,7 +203,8 @@ function exec_export_all_dist()
 			export_objets($table, primary_index_table($table), $tables_for_link[$table], 0, false, $i, _T("info_sauvegarde").", $table");
 		}
 
-		ob_flush();flush();
+		if ($GLOBALS['flag_ob_flush']) ob_flush();
+		flush();
 		ramasse_parties($file, $gz, $partfile);
 
 		$f = ($gz) ? gzopen($file, "ab") : fopen($file, "ab");
@@ -291,7 +294,8 @@ function export_objets($table, $primary, $liens, $file = 0, $gz = false, $etape_
 		}
 		if ($pos_in_table!=0)
 			echo "| ", $pos_in_table;
-		ob_flush();flush();
+		if ($GLOBALS['flag_ob_flush']) ob_flush();
+		flush();
 
 		if ($limit == 0) $limit=$total;
 		$result = spip_query("SELECT * FROM $table LIMIT $debut,$limit");
@@ -326,11 +330,13 @@ function export_objets($table, $primary, $liens, $file = 0, $gz = false, $etape_
 	else if ($etape_actuelle < $etape_en_cours) {
 		if (!isset($etape_affichee[$etape_actuelle]))
 			echo "<li>", $etape_actuelle,'-',$nom_etape,"</li>";
-		ob_flush();flush();
+		if ($GLOBALS['flag_ob_flush']) ob_flush();
+		flush();
 	} else {
 		if (!isset($etape_affichee[$etape_actuelle]))
 			echo "<li> <font color='#999999'>",$etape_actuelle,'-',$nom_etape,'</font></li>';
-		ob_flush();flush();
+		if ($GLOBALS['flag_ob_flush']) ob_flush();
+		flush();
 	}
 	return array($string,$status_dump);
 }
diff --git a/ecrire/inc/import.php b/ecrire/inc/import.php
index 64732c88e6..e31018baa9 100644
--- a/ecrire/inc/import.php
+++ b/ecrire/inc/import.php
@@ -21,6 +21,7 @@ include_spip('inc/auxbase');
 global $IMPORT_tables_noerase;
 $IMPORT_tables_noerase[]='spip_ajax_fonc';
 $IMPORT_tables_noerase[]='spip_meta';
+$GLOBALS['flag_ob_flush'] = function_exists('ob_flush');
 
 function xml_fetch_tag($f, &$before, $gz=false, $skip_comment=true) {
 	global $buf, $abs_pos;
@@ -234,7 +235,8 @@ function detruit_restaurateur()
 function affiche_progression_javascript($abs_pos,$table="") {
 	global $affiche_progression_pourcent;
 	include_ecrire('inc_charsets');
-	ob_flush();flush();
+	if ($GLOBALS['flag_ob_flush']) ob_flush();
+	flush();
 	echo " -->\n<script type='text/javascript'><!--\n";
 
 	if ($abs_pos == '100 %') {
@@ -258,7 +260,8 @@ function affiche_progression_javascript($abs_pos,$table="") {
 		echo "//--></script>\n<!--\n";
 	}
 
-	ob_flush();flush();
+	if ($GLOBALS['flag_ob_flush']) ob_flush();
+	flush();
 }
 
 
@@ -386,7 +389,8 @@ function import_all_continue()
 	echo ("<script language=\"JavaScript\" type=\"text/javascript\">window.setTimeout('location.href=\"".self()."\";',$max_time);</script>\n");
 
 	fin_page();
-	ob_flush();flush();
+	if ($GLOBALS['flag_ob_flush']) ob_flush();
+	flush();
 
 	echo "<font color='white'>\n<!--";
 
-- 
GitLab