diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bccbae..ab47196 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added methods for retrieving task lists (lending requests and requested resources). +## [0.7.1] - 2018-10-23 + +### Fixed + +- Fixed infinite loop in `Users::search()` when search result only contained contacts. + ## [0.7.0] - 2018-09-02 ### Added @@ -65,6 +71,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. tbd. -[Unreleased]: https://github.com/scriptotek/php-marc/compare/v0.6.1...HEAD +[Unreleased]: https://github.com/scriptotek/php-marc/compare/v0.7.1...HEAD +[0.7.1]: https://github.com/scriptotek/php-marc/compare/v0.7.0...v0.7.1 [0.7.0]: https://github.com/scriptotek/php-marc/compare/v0.6.1...v0.7.0 [0.6.1]: https://github.com/scriptotek/php-marc/compare/v0.6.0...v0.6.1 diff --git a/src/Users/Users.php b/src/Users/Users.php index c0b942a..f0e95ee 100644 --- a/src/Users/Users.php +++ b/src/Users/Users.php @@ -97,7 +97,7 @@ public function search($query, array $options = []) break; } - if (!isset($response->user)) { + if (!isset($response->user) || empty($response->user)) { // We cannot trust the value in 'total_record_count', so if there are no more records, // we have to assume the result set is depleted. // See: https://github.com/scriptotek/php-alma-client/issues/7 @@ -105,6 +105,7 @@ public function search($query, array $options = []) } foreach ($response->user as $data) { + $offset++; // Contacts without a primary identifier will have the primary_id // field populated with something weird like "no primary id (123456789023)". // We ignore those. @@ -118,7 +119,6 @@ public function search($query, array $options = []) $user->init(); } yield $user; - $offset++; } if ($offset >= $response->total_record_count) { break;