improved out buffer function handling;

bug #1690064 headers already sent error if OBGzip = 0
This commit is contained in:
Sebastian Mendel
2007-03-29 07:10:15 +00:00
parent a190872f0a
commit 3626acdb24
7 changed files with 21 additions and 83 deletions

View File

@@ -14,12 +14,8 @@ require_once('./libraries/common.inc.php');
PMA_checkParameters(array('db', 'table', 'field'));
require_once('./libraries/ob.lib.php');
if ($cfg['OBGzip']) {
$ob_mode = PMA_outBufferModeGet();
if ($ob_mode) {
PMA_outBufferPre($ob_mode);
}
}
PMA_outBufferPre();
require_once('./libraries/header_http.inc.php');
$field = urldecode($field);
@@ -298,13 +294,4 @@ if (isset($controllink) && $controllink) {
if (isset($userlink) && $userlink) {
@PMA_DBI_close($userlink);
}
/**
* Sends bufferized data
*/
if (isset($cfg['OBGzip']) && $cfg['OBGzip']
&& isset($ob_mode) && $ob_mode) {
PMA_outBufferPost($ob_mode);
}
?>

View File

@@ -40,7 +40,6 @@
* @uses PMA_getenv()
* @uses PMA_generate_common_url()
* @uses PMA_DBI_close()
* @uses PMA_outBufferPost()
* @uses basename()
* @uses file_exists()
* @version $Id$
@@ -189,11 +188,6 @@ if (! empty($GLOBALS['cfg']['DBG']['enable'])
</body>
</html>
<?php
/**
* Sends bufferized data
*/
PMA_outBufferPost();
/**
* Stops the script execution
*/

View File

@@ -17,12 +17,7 @@ if (empty($GLOBALS['is_header_sent'])) {
*/
require_once './libraries/common.inc.php';
require_once './libraries/ob.lib.php';
if ($GLOBALS['cfg']['OBGzip']) {
$GLOBALS['ob_mode'] = PMA_outBufferModeGet();
if ($GLOBALS['ob_mode']) {
PMA_outBufferPre($GLOBALS['ob_mode']);
}
}
PMA_outBufferPre();
// garvin: For re-usability, moved http-headers and stylesheets
// to a seperate file. It can now be included by header.inc.php,

View File

@@ -10,12 +10,7 @@
*/
require_once('./libraries/common.inc.php');
require_once('./libraries/ob.lib.php');
if ($cfg['OBGzip']) {
$ob_mode = PMA_outBufferModeGet();
if ($ob_mode) {
PMA_outBufferPre($ob_mode);
}
}
PMA_outBufferPre();
// Check parameters

View File

@@ -17,11 +17,10 @@
* because both header and footer functions must know what each other is
* doing.
*
* @uses $GLOBALS['cfg']['OBGzip']
* @uses $cfg['OBGzip']
* @uses function_exists()
* @uses ini_get()
* @uses ob_get_level()
* @uses header()
* @staticvar integer remember last calculated value
* @return integer the output buffer mode
*/
@@ -60,8 +59,6 @@ function PMA_outBufferModeGet()
// Usefull if we ever decide to combine modes. Then a bitmask field of
// the sum of all modes will be the natural choice.
header('X-ob_mode: ' . $mode);
return $mode;
} // end of the 'PMA_outBufferModeGet()' function
@@ -72,26 +69,20 @@ function PMA_outBufferModeGet()
* the PMA_outBufferModeGet() function or it will be useless.
*
* @uses PMA_outBufferModeGet()
* @uses PMA_outBufferPost() to register it as shutdown function
* @uses ob_start()
* @param integer $mode DEPRECATED
* @return boolean whether output buffering is enabled or not
* @uses header() to send X-ob_mode:
* @uses register_shutdown_function() to register PMA_outBufferPost()
*/
function PMA_outBufferPre($mode = null)
function PMA_outBufferPre()
{
switch(PMA_outBufferModeGet())
{
case 1:
ob_start('ob_gzhandler');
$retval = true;
break;
if ($mode = PMA_outBufferModeGet()) {
ob_start('ob_gzhandler');
}
case 0:
default:
$retval = false;
break;
} // end switch
header('X-ob_mode: ' . $mode);
return $retval;
register_shutdown_function('PMA_outBufferPost');
} // end of the 'PMA_outBufferPre()' function
@@ -103,27 +94,14 @@ function PMA_outBufferPre($mode = null)
* @uses PMA_outBufferModeGet()
* @uses ob_flush()
* @uses flush()
* @param integer $mode DEPRECATED
* @return boolean whether data has been send from the buffer or not
*/
function PMA_outBufferPost($mode = null)
function PMA_outBufferPost()
{
switch(PMA_outBufferModeGet())
{
case 1:
# This output buffer doesn't need a footer.
ob_flush();
$retval = true;
break;
case 0:
default:
flush();
$retval = false;
break;
} // end switch
return $retval;
if (PMA_outBufferModeGet()) {
ob_flush();
} else {
flush();
}
} // end of the 'PMA_outBufferPost()' function
?>

View File

@@ -52,7 +52,6 @@ require_once './libraries/common.inc.php';
*
* @uses $GLOBALS['controllink'] to close it
* @uses $GLOBALS['userlink'] to close it
* @uses PMA_outBufferPost()
* @uses PMA_DBI_close()
* @access private only to be used in navigation.php
*/
@@ -70,12 +69,7 @@ function PMA_exitNavigationFrame()
@PMA_DBI_close($GLOBALS['userlink']);
}
/**
* Sends bufferized data
*/
PMA_outBufferPost();
exit();
exit;
}
// free the session file, for the other frames to be loaded

View File

@@ -311,9 +311,4 @@ if (! empty($controllink)) {
if (! empty($userlink)) {
PMA_DBI_close($userlink);
}
/**
* Sends bufferized data
*/
PMA_outBufferPost();
?>