Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conflict between php zlib.output_compression and output buffering #2182

Closed
gixxy22 opened this issue Sep 3, 2019 · 3 comments
Closed

conflict between php zlib.output_compression and output buffering #2182

gixxy22 opened this issue Sep 3, 2019 · 3 comments

Comments

@gixxy22
Copy link

gixxy22 commented Sep 3, 2019

Describe the bug
When zlib.output_compression is set to On in php.ini, CI4 cannot display any views and produces headers already sent errors.

CodeIgniter 4 version
CodeIgniter 4.0 RC1

Affected module(s)
/app/Config/Events.php
Removing this code in app/Config/Events.php, or turning off output_compression in php.ini is a temp solution.

while (\ob_get_level() > 0)
	{
		\ob_end_flush();
	}

	\ob_start(function ($buffer) {
		return $buffer;
	});

Context

  • OS: Centos 7
  • Web server: Apache/2.4.41
  • PHP version: 7.2.1
@jim-parry jim-parry added this to the 4.0.0-rc.2 milestone Sep 8, 2019
@jim-parry
Copy link
Contributor

This sounds like a PHP problem, not a CodeIgniter one.
From https://www.php.net/manual/en/zlib.configuration.php:
"... a hard to spot gotcha when implementing zlib.output_compression. if you use flush() anywhere in your script (even right at the end) the compression won't work - you need to let that happen automatically or it ends up being sent uncompressed."
CodeIgniter view rendering and unit testing rely on output buffering, and flush().

@starchild
Copy link

Exactly the same issue for us too.

Surely not being able to use compression is a bad thing?

@PedroRuiz
Copy link

PedroRuiz commented May 20, 2021

I have the same issue. So, a fake solution is

if (ENVIRONMENT !== 'testing')
	{

		if (ini_get('zlib.output_compression'))

		{

			return true; //throw FrameworkException::forEnabledZlibOutputCompression();

		}

I hope this help. It's fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants