Jump to content

Recommended Posts

I am having an issue with a local intranet script that has been running problem free for many months now.  Earlier this week I upgraded the PHP version on the sever as a requirement for a separate script that was upgraded on the server.  When I did this, I did not change the php.ini configuration, or ANY code on this script.  Now when I run this script it hangs.

 

I have narrowed down the script to a single line of code, and a even a single function: file_get_contents()

 

The return from the function is quick.  I can see the return echo'ed out and the script continues processing after that.  What does not happen is the page becoming "ready".  The page is in a "loading" stage for 3+ seconds longer than it needs to be.  My thought is that the problem lies in closing the connection with the file, but I cannot verify that.  I have tried using the fopen()/fread()/fclose(), stream_get_contents() and even some quick and dirty curl, but those all suffer from the same lag.

 

Here are come quick before and after benchmarks:

PHP 5.1.2 - 0.652, 0.813, 0.703

PHP 5.2.4 - 5.672, 5.547, 5.563

 

I am able to downgrade the PHP installation and the performance issues goes away.  I have tried upgrading to to 5.2.5 and even using the recommended php.ini for that setup, but the problem does not go away.

 

I have asked this question on another forum, but I was unable to get any solutions: http://www.sitepoint.com/forums/showthread.php?t=528407

 

Can any of the PHP gurus think of a cause of this problem?  Or maybe even a temporary work around?

Link to comment
https://forums.phpfreaks.com/topic/88607-upgraded-php-and-file_get_contents-hangs/
Share on other sites

My one and only bump.  I would really like to find a work around for this.  Currently, we are using a temporary work around that requests and saves an entire batch of orders at once.  The old script did it per order, as needed, which allowed for error handling.

Very simple:

	$promo_content = file_get_contents("http://www.MYDOMAIN.com/scripts/check_order_promo.php?order=".$ordernum);
if ($promo_content == 1) {
//this order wants a promotional item
}

 

MYDOMAIN.com is not the only domain that is experiencing the lag.  Also, as stated above, the lag is not in the response, but actually when the page finishes rendering.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.