From 17cb74259e90bd0dcf8a23288a10cdbfed3f9e59 Mon Sep 17 00:00:00 2001 From: Vladas Lapinskas Date: Sat, 29 Feb 2020 06:36:51 +0000 Subject: [PATCH] Performance improvements in 1.0.7 --- CHANGELOG.md | 8 ++++++++ composer.json | 2 +- src/Request.php | 12 ++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d4557f..098e3df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ # Changelog +## [1.0.7] - 2020-02-29 + +### Added + +- Session startup could be conditional. Thanks to @jcheron + ## [1.0.6] - 2020-02-27 ### Fixed @@ -23,6 +29,8 @@ - First stable release + +[1.0.7]: https://github.com/Lapinskas/roadrunner-ubiquity/releases/tag/1.0.7 [1.0.6]: https://github.com/Lapinskas/roadrunner-ubiquity/releases/tag/1.0.6 [1.0.4]: https://github.com/Lapinskas/roadrunner-ubiquity/releases/tag/1.0.4 [1.0.3]: https://github.com/Lapinskas/roadrunner-ubiquity/releases/tag/1.0.3 diff --git a/composer.json b/composer.json index 9c03e84..d23efbc 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "lapinskas/roadrunner-ubiquity", "type": "library", - "version": "1.0.6", + "version": "1.0.7", "description": "RoadRunner and Ubiquity integration", "keywords": ["roadrunner","ubiquity"], "homepage": "https://github.com/Lapinskas/roadrunner-ubiquity", diff --git a/src/Request.php b/src/Request.php index f789726..d3f11dd 100644 --- a/src/Request.php +++ b/src/Request.php @@ -28,6 +28,8 @@ class Request private $hasSession; + private $uri; + /** * Request constructor. * Opens stream relay with RoadRunner @@ -115,7 +117,7 @@ public function sendResponse(int $status = 200, string $body = null, array $head */ public function ubiquityRoute() { - $uri = \ltrim(\urldecode(\parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)), '/'); + $uri = \ltrim($this->uri, '/'); return $_GET['c'] = ($uri !== 'favicon.ico' && ($uri == null || ! \file_exists(__DIR__ . '/' . $uri))) ? $uri : ''; } @@ -131,7 +133,6 @@ public function garbageCollect($softLimit = self::MEMORY_SOFT_LIMIT) if ($softLimit <= memory_get_usage()) { gc_collect_cycles(); } - ; } /** @@ -152,7 +153,7 @@ public function getWorker(): Worker */ protected function prepareServer(): array { - $ctx = $this->rawRequest['ctx']; + $ctx = &$this->rawRequest['ctx']; $server = $this->originalServer; @@ -177,10 +178,9 @@ protected function prepareServer(): array if (false !== $parts = parse_url($ctx['uri'])) { $server['QUERY_STRING'] = $parts['query'] ?? null; - $server['REQUEST_URI'] = $parts['path'] ?? null; + $server['REQUEST_URI'] = $this->uri = $parts['path'] ?? null; $server['SERVER_PORT'] = $parts['port'] ?? null; } - ; return $server; } @@ -230,7 +230,7 @@ protected function prepareCookie(): array */ protected function prepareFiles(): array { - $ctx = $this->rawRequest['ctx']; + $ctx = &$this->rawRequest['ctx']; if (! isset($ctx['uploads'])) { return [];