MDL-51603 dataformats: coding_exception if output buffering

This commit is contained in:
David Monllao 2016-04-21 14:47:09 +08:00
parent 5b95105600
commit 9df4ae4189
4 changed files with 5 additions and 10 deletions

View File

@ -38,8 +38,8 @@
*/
function download_as_dataformat($filename, $dataformat, $columns, $iterator, $callback = null) {
if (!NO_OUTPUT_BUFFERING) {
throw new coding_exception("NO_OUTPUT_BUFFERING must be set to true before calling download_as_dataformat");
if (ob_get_length()) {
throw new coding_exception("Output can not be buffered before calling download_as_dataformat");
}
$classname = 'dataformat_' . $dataformat . '\writer';

View File

@ -1704,10 +1704,8 @@ class table_dataformat_export_format extends table_default_export_format_parent
public function __construct(&$table, $dataformat) {
parent::__construct($table);
if (!NO_OUTPUT_BUFFERING) {
// Ideally this would throw a coding exception but we are more forgiving here due
// to the large amount of code already using table_sql.
debugging("NO_OUTPUT_BUFFERING should be set to true before downloading", DEBUG_DEVELOPER);
if (ob_get_length()) {
throw new coding_exception("Output can not be buffered before instantiating table_dataformat_export_format");
}
$classname = 'dataformat_' . $dataformat . '\writer';

View File

@ -116,6 +116,7 @@ information provided here is intended especially for developers.
* behat_util::is_server_running() is removed, please use behat_util::check_server_status() instead.
* Behat\Mink\Selector\SelectorsHandler::xpathLiteral() method is deprecated use behat_context_helper::escape instead
when building Xpath, or pass the unescaped value when using the named selector.',
* table_sql download process is using the new data formats plugin which you can't use if you are buffering any output
=== 3.0 ===

View File

@ -22,10 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
if (!empty($_GET['download'])) {
define('NO_OUTPUT_BUFFERING', true);
}
require('../../config.php');
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot.'/report/log/locallib.php');