Notice: ob_flush(): failed to flush buffer. No buffer to flush in drupal_page_footer() (line 2562 of includes\common.inc)

This notice never appears on-screen, only in the logs:

Type	php
Date	Thursday, May 19, 2011 - 19:30
User	admin
Location	http://drupal.test/sites/default/files/styles/medium/public/
Referrer	http://drupal.test/
Message	Notice: ob_flush(): failed to flush buffer. No buffer to flush in drupal_page_footer() (line 2562 of includes\common.inc).
Severity	notice

Potentially related issues:
#732542: system_goto_action breaks core APIs
#772274: drupal_send_headers

However, none of them seems to be about this particular error.

Comments

sun’s picture

Just discovered that above mentioned notice always and consistently appears after this 404:

Type	page not found
Date	Thursday, May 19, 2011 - 19:30
User	admin
Location	http://drupal.test/sites/default/files/styles/medium/public/
Referrer	http://drupal.test/
Message	sites/default/files/styles/medium/public
Severity	warning
davisben’s picture

I was experiencing this as well. The cause was an empty, but required, image field on my content type. When the image field was added it wasn't required and content was created with no image. After changing it to be required, I was getting these errors in the log when using the update options at admin/content.

davisben’s picture

Actually, the image field didn't exist on the content type at first, but was added as a required field after some content had been created. Not sure if it makes any difference.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

longwave’s picture

Issue summary: View changes
Status: Active » Closed (outdated)
Issue tags: +Bug Smash Initiative

drupal_page_footer() no longer exists and we don't even call ob_flush() anywhere in core now. Closing as outdated.

Graham Leach’s picture

Hello Everyone,

if you run

$php index.php

in your Drupal 7 root, you will probably still get this. I do:

</html>[notice] [php] [127.0.0.1] [uid:0] [http:///index.php?index.php] [] Notice: ob_flush(): failed to flush buffer. No buffer to flush in drupal_page_footer() (line 2821 of /var/www/dev.holisticpethelp.com/mobile/includes/common.inc).

So it's still around, and Drupal 7 is still officially supported for another 9 months.....soooooooo.......

The offending line is in the drupal_page_footer() function:

/**
 * Performs end-of-request tasks.
 *
 * This function sets the page cache if appropriate, and allows modules to
 * react to the closing of the page by calling hook_exit().
 */
function drupal_page_footer() {
  global $user;

  module_invoke_all('exit');

  // Commit the user session, if needed.
  drupal_session_commit();

  if (variable_get('cache', 0) && ($cache = drupal_page_set_cache())) {
    drupal_serve_page_from_cache($cache);
  }
  else {
    ob_flush();
  }

  _registry_check_code(REGISTRY_WRITE_LOOKUP_CACHE);
  drupal_cache_system_paths();
  module_implements_write_cache();
  drupal_file_scan_write_cache();
  system_run_automated_cron();
}

The issue seems to be that the code assumes that there will always be something to do with ob_flush(), when that isn't (maybe) always the case.

ob_flush() is a PHP native function that basically tells PHP to clear (or "flush") the Output Buffer.

Handily, there is a function to test to see if there is something in the Output Buffer: ob_get_contents()

If ob_get_contents returns FALSE then ob_flush() shouldn't be called.

So, here's the fix:

else {
ob_flush();
}

Becomes

else {
if (!ob_get_contents) ob_flush();
}

g.