Skip to content

Commit

Permalink
Fixes PHP warning when trying to get ready request IDs, #14
Browse files Browse the repository at this point in the history
  • Loading branch information
hollodotme committed Nov 18, 2017
1 parent 6c60054 commit f657930
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com).

## [1.4.1] - 2017-11-19

* Fixes PHP warning when trying to get ready request IDs - [#14]

## [1.4.0] - 2017-09-28

### Added
Expand Down Expand Up @@ -104,6 +108,7 @@ Based on [Pierrick Charron](https://github.com/adoy)'s [PHP-FastCGI-Client](http
* Getters/Setters for connect timeout, read/write timeout, keep alive, socket persistence from `Client` (now part of the socket connection)
* Method `Client->getValues()`

[1.4.1]: https://github.com/hollodotme/fast-cgi-client/compare/v1.4.0...v1.4.1
[1.4.0]: https://github.com/hollodotme/fast-cgi-client/compare/v1.3.0...v1.4.0
[1.3.0]: https://github.com/hollodotme/fast-cgi-client/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/hollodotme/fast-cgi-client/compare/v1.1.0...v1.2.0
Expand All @@ -117,3 +122,4 @@ Based on [Pierrick Charron](https://github.com/adoy)'s [PHP-FastCGI-Client](http
[#6]: https://github.com/hollodotme/fast-cgi-client/issues/6
[#9]: https://github.com/hollodotme/fast-cgi-client/issues/9
[#11]: https://github.com/hollodotme/fast-cgi-client/issues/11
[#14]: https://github.com/hollodotme/fast-cgi-client/issues/14
10 changes: 6 additions & 4 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ public function hasResponse( int $requestId ) : bool
*/
public function getRequestIdsHavingResponse() : array
{
if ( \count( $this->sockets ) === 0 )
{
return [];
}

$resources = [];
$writes = $excepts = null;

Expand Down Expand Up @@ -343,9 +348,6 @@ public function handleReadyResponses( $timeoutMs = null )
{
$requestIds = $this->getRequestIdsHavingResponse();

if ( \count( $requestIds ) > 0 )
{
$this->handleResponses( $timeoutMs, ...$requestIds );
}
$this->handleResponses( $timeoutMs, ...$requestIds );
}
}
10 changes: 10 additions & 0 deletions tests/Unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,14 @@ public function testConnectAttemptToRestrictedUnixDomainSocketThrowsException()

$client->sendRequest( new PostRequest( '/path/to/script.php', '' ) );
}

public function testHandlingReadyResponsesJustReturnsIfClientGotNoRequests()
{
$connection = new UnixDomainSocket( '/var/run/php7.0-ruds.sock' );
$client = new Client( $connection );

$this->assertFalse( $client->hasUnhandledResponses() );

$client->handleReadyResponses();
}
}

0 comments on commit f657930

Please sign in to comment.