PHP 5.4.24 timeout due to ob_start() - php

I am trying to run this set of code
public function getDataCellContent($row,$data) {
ob_start();
$this->renderDataCellContent($row,$data);
return ob_get_clean();
}
When it hits the ob_start() line it just hangs and times out after 30 seconds. I am having this issue on Mac Osx Mavericks. I have an ubuntu server running the same code without this issue happening. Is something messed up with my ini file or is php 5.4.* known to have this issue?

Related

PHP Script didn't abort after max_execution_time (XAMPP, XDebug)

I have a PHP script with infinity loop.
When I run this script using AJAX or directly in browser the server is trying to execute this script. The problem is: After 30 seconds the server is still executing the script. There is no "Maximum execution time exceeded" error. In the php.ini file max_execution_time is set to 30. Because of this problem, server is no longer usable. I can't run any other script by AJAX. I have to restart Apache in XAMPP.
Why the server didn't abort after 30 seconds?
I'm using XAMPP and XDebug.
// UPDATE 1:
PHP Script:
<?php
while(true)
echo 'test';
I know that this code have no sense. I just wondering, why the server didn't abort execution after 30 seconds...
**//UPDATE 2: ** I turned off XDebug, and change code to:
<?php
$x = 0;
while(true)
$x += 1;
Now it's ok: the server abort script after 30 sec with "max execution time" error.
However, the server still can't abort script with "echo" statement (even with with disabled XDebug). The same problem is when I try to execute script without "echo", but with enabled XDebug.
So, it seems to be problem when I use "echo" or "XDebug".
The script is corretly aborted only if there is no 'echo' and XDebug is disabled.
I ran into this issue as well. For me, once xdebug was enabled and autostarted, max_execution_time was set to 0 no matter what. I had to disable it to have it as a value. At least now I know that in my development environment, timeout testing is not possible while xdebug is enabled.
In my case, the script would get killed by the web server without running the register_shutdown_function. Since PHP wasn't handling the timeout, I'd get no errors except for the internal 500 error. Bugsnag wouldn't get notified.
I have make changes in my case in:
xampp\phpMyAdmin\libraries\config.default.php
search for : `$cfg['ExecTimeLimit']
You can change Right hand Value to any higher value, like '6000'.
and it works for me.
Done!
I turned off "Litening for PHP Debug Connections" in PHP Storm and the problem is solved.

503 timeout on PHP 5.6.31

I have two and more servers running PHP 5.4.45 with same scripts and none of them are doing any issue when calling a script that requires more than 60 seconds to finish.
However, a new server having PHP 5.6.31 is returning 503 timeout, when I run the same script. I tried everything found on the internet from keepAlive to timeout in httpd.conf and in php.ini, I already have
ini_set('memory_limit', '-1');
ini_set('max_execution_time', 5);
Inside the code and all that. Same script same everything just different PHP version on 5.4.45 it works perfectly while on 5.6.31 I always get timeout unless when the full script executes in less than 60 seconds [I don't know where that limit comes from eventhough I changed anything related to 60 from the httpd.conf and php.ini) .
Kindly can you help me troubleshoot.

php's set_time_limit(0) hangs and throws HTTP 500

This simple test, that calls set_time_limit 10 times:
<?php
echo("<html><head><title>set_time test</title></head><body><h1>set_time test</h1>");
for ($i=0; $i<10; $i++) {
error_log("Round $i");
set_time_limit(0); echo("<p>$i</p>");
}
echo("</body></html>");
Hangs forever with error:
// Fatal error: Maximum execution time of 30 seconds exceeded in .../_set_time.php on line 4
// Call Stack:
// 0.0007 231768 1. {main}() .../_set_time.php:0
// 0.0007 232000 2. set_time_limit() .../_set_time.php:4
30 seconds is the value of max_execution_time in php.ini. If I raise it to 3000, the scripts just keeps spinning. I have AllowOverrideAll for the document root in apache's config (assuming it matters - it shouldn't, but still)
A similar machine (same OS & SW versions, config very close) runs the script flawlessly each time. Log files show nothing. Google searches are mostly silently or irrelevant. Seems some weird system/configuration quirk.
Ideas?
OS: CentOS 6.9
apache 2.2.15
php 5.6 (webtatic RPM:php56w-5.6.30-1.w6.x86_64)
Edit: Submitted to the xdebug project as bug: https://bugs.xdebug.org/view.php?id=1457
OK, so the culprit is the xdebug extension (installed on one machine but not on the other). By removing it (php56w-pecl-xdebug-2.5.3-1.w6.x86_64) the unwanted behavior disappears. Bit tricky, took more than 2 days to pinpoint, between narrowing it to set_time_limit and finding the responsible extension.

php 5.3 causing flush() to fail?

I have two Linux hosting plans with godaddy. One (older runs) php 5.2.14, newer runs php 5.3.6. I use Firefox 11.0 and IE 9 on Vista.
PHP below runs ok with php 5.2.17 (numbers appear every half second) until the script finishes. Hosting that uses PHP 5.3.6, will not work. It loads for a while, then flushes the entire output at once after the script is done. No intermediate output.
php.ini has output_buffering = Off and zlib.output_compression = Off. Does anyone know how I can make this work under PHP 5.3?
Thanks,
emmets
<?php
$i = 0;
while ($i<=10)
{
echo “i=$i “;
flush();
echo(str_repeat(‘ ‘,1024));
usleep(500000);
$i++;
}
?>
https://bugs.php.net/bug.php?id=49816
It seems to be a known bug.

AjaXplorer [written in PHP] is too slow on IIS

I've installed AjaXplorer (very nice web file explorer), written in PHP, on my IIS (Windows Server 2008 SP2 x64). It works too slow for me.
What can be the cause? Are there some settings in php.ini? Or, maybe, something is wrong with IIS?
I use 32-bit PHP, php-cgi.exe as interpreter.
Regards,
First off, CGI will always be slow. It needs to boot the entire PHP runtime for each request. Try using FastCGI (If you're using IIS 7, or if you're using IIS 6)...
After that, try to see why it's slow. Is it because the PHP script takes a long time to execute (meaning it's a code issue), or is it because of a server config. To test, modify this into the start of the entrance point of the PHP program (index.php):
define(START_TIME_CUSTOM, microtime(true));
function onEndTimeCompute() {
$timeTaken = microtime(true) - START_TIME_CUSTOM;
echo "Completed In: ".number_format($timeTaken, 4)." Seconds\n";
}
register_shutdown_function('onEndTimeCompute');
That write Completed in n Seconds to the end of the generated output (even if die() is called). It may cause some issues if Ajax calls are expected to return JSON, so don't do it as a rule, just for trying to figure out what's going on.
So, if the total request takes 1 second, yet you see Completed in 0.004 Seconds, you know that the PHP code itself is not the issue (it's either in the setup of the interpreter by CGI, or somewhere else in IIS)...
That should at least show you where the problem is...

Categories