From b02fd5232ce1aac73c5c08cf8b5c66ddbe412584 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Thu, 24 May 2012 02:01:24 +0200 Subject: [PATCH 1/5] Fixing a bug that would stop the script execution before the laravel.done event has been fired for php-fastcgi users Signed-off-by: Koen Schmeets --- laravel/laravel.php | 6 +++++- .../vendor/Symfony/Component/HttpFoundation/Response.php | 4 ---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/laravel/laravel.php b/laravel/laravel.php index a1ca2061..c3fef2ee 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -178,4 +178,8 @@ | */ -Event::fire('laravel.done', array($response)); \ No newline at end of file +Event::fire('laravel.done', array($response)); + +if (function_exists('fastcgi_finish_request')) { + fastcgi_finish_request(); +} \ No newline at end of file diff --git a/laravel/vendor/Symfony/Component/HttpFoundation/Response.php b/laravel/vendor/Symfony/Component/HttpFoundation/Response.php index 3a0a22e4..dacf4722 100755 --- a/laravel/vendor/Symfony/Component/HttpFoundation/Response.php +++ b/laravel/vendor/Symfony/Component/HttpFoundation/Response.php @@ -292,10 +292,6 @@ public function send() $this->sendHeaders(); $this->sendContent(); - if (function_exists('fastcgi_finish_request')) { - fastcgi_finish_request(); - } - return $this; } From 0f3e8eb62ba3f9e849e2ff7b777dd4b3af92a9c1 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Thu, 24 May 2012 11:49:35 +0200 Subject: [PATCH 2/5] Reverting Symfony's Response class to previous version Signed-off-by: Koen Schmeets --- laravel/vendor/Symfony/Component/HttpFoundation/Response.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/laravel/vendor/Symfony/Component/HttpFoundation/Response.php b/laravel/vendor/Symfony/Component/HttpFoundation/Response.php index dacf4722..3a0a22e4 100755 --- a/laravel/vendor/Symfony/Component/HttpFoundation/Response.php +++ b/laravel/vendor/Symfony/Component/HttpFoundation/Response.php @@ -292,6 +292,10 @@ public function send() $this->sendHeaders(); $this->sendContent(); + if (function_exists('fastcgi_finish_request')) { + fastcgi_finish_request(); + } + return $this; } From 52fded661d6c1a2faafffe8374f7771f8b351400 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Thu, 24 May 2012 11:50:48 +0200 Subject: [PATCH 3/5] Extending Symfony's Response class and adding & calling the finish method Signed-off-by: Koen Schmeets --- laravel/laravel.php | 4 +- laravel/response.php | 2 +- .../HttpFoundation/LaravelResponse.php | 40 +++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 laravel/vendor/Symfony/Component/HttpFoundation/LaravelResponse.php diff --git a/laravel/laravel.php b/laravel/laravel.php index c3fef2ee..fcdc32c5 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -180,6 +180,4 @@ Event::fire('laravel.done', array($response)); -if (function_exists('fastcgi_finish_request')) { - fastcgi_finish_request(); -} \ No newline at end of file +$response->finish(); \ No newline at end of file diff --git a/laravel/response.php b/laravel/response.php index e5472430..539f5649 100644 --- a/laravel/response.php +++ b/laravel/response.php @@ -1,7 +1,7 @@ + * + * @api + */ +class LaravelResponse extends Response +{ + + /** + * Sends HTTP headers and content. + * + * @return Response + * + * @api + */ + public function send() + { + $this->sendHeaders(); + $this->sendContent(); + + return $this; + } + + /** + * Finishes the request for PHP-FastCGI + * + * @return void + */ + public function finish() + { + if (function_exists('fastcgi_finish_request')) { + fastcgi_finish_request(); + } + } + +} From 189f3813d040dcf33b2eb91b0519afa3624e9fe4 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Sat, 16 Jun 2012 13:20:39 +0200 Subject: [PATCH 4/5] Calling the finish method on the right object --- laravel/laravel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/laravel.php b/laravel/laravel.php index fcdc32c5..990c8cee 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -180,4 +180,4 @@ Event::fire('laravel.done', array($response)); -$response->finish(); \ No newline at end of file +$response->foundation->finish(); \ No newline at end of file From 276f96aec303bb25a714c5ad12d50f2c69aa7ae9 Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Wed, 20 Jun 2012 19:27:24 +0200 Subject: [PATCH 5/5] Adding comment to finish call --- laravel/laravel.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/laravel/laravel.php b/laravel/laravel.php index 990c8cee..542c945d 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -180,4 +180,16 @@ Event::fire('laravel.done', array($response)); +/* +|-------------------------------------------------------------------------- +| Finish the request for PHP-FastCGI +|-------------------------------------------------------------------------- +| +| Stopping the PHP process for PHP-FastCGI users to speed up some +| PHP queries. Acceleration is possible when there are actions in the +| process of script execution that do not affect server response. +| For example, saving the session in memcached can occur after the page +| has been formed and passed to a web server. +*/ + $response->foundation->finish(); \ No newline at end of file