Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAX ROWS with offset #4

Closed
bit-forge opened this issue Jun 25, 2012 · 2 comments
Closed

MAX ROWS with offset #4

bit-forge opened this issue Jun 25, 2012 · 2 comments

Comments

@bit-forge
Copy link

Murphy's Law is in play, and my RETS server has a result set that returns a total set size that is an exact multiple of MAX ROWS. So, MAX ROWS is 500, and the total result set is 2000, necessitating four batches in SearchQuery. The problem is that on the last batch, MAX ROWS is set by the server, but it's also the last possible result set because and offset value of 2001 will return an offset error from the RETS server. Based on how maxrows_reached is set, the query always errors out with this data set, because it always tries to request one more batch than necessary.

My rather ham-fisted fix is:

if (isset($xml->MAXROWS)) {
// MAXROWS tag found. the RETS server withheld records.
// if the server supports Offset, more requests can be sent to page through results
// until this tag isn't found anymore.
if(isset($xml->COUNT)) {
// Check to see if this is the last batch based on the total size of the result set. Server may set MAX ROWS even if this
// batch is the last possible set, if the total records found is perfectly divisible by max rows.
if($this->NumRows($this->int_result_pointer) < $this->search_data[$this->int_result_pointer]['total_records_found']) {
$this->search_data[$this->int_result_pointer]['maxrows_reached'] = true;
}
} else {
$this->search_data[$this->int_result_pointer]['maxrows_reached'] = true;
}
}

Not knowing enough about the internals of phRETS I didn't want to do a pull request, as I thought this is probably not the optimal solution.

@imcjeff
Copy link

imcjeff commented Aug 21, 2015

We're currently running into problems with this same error ([Offset] is beyond the number of returnable records.). Where would I go about implementing the solution in this post? Or, is there another workaround for this problem that's come up since this was first posted?

@troydavisson
Copy link
Owner

With 2.x, it includes the ability to override the logic used to determine when to continue pagination. If instances where someone is interacting with a non-compliant server, that logic can be changed to support a different algorithm.

collegeman added a commit to collegeman/PHRETS that referenced this issue Jul 7, 2017
Running version 2.4 on PHP 7.1.4, was getting an error message:

[2017-07-07 18:23:35] local.ERROR: ErrorException: PHRETS\Parsers\GetMetadata\System::parse(): Node no longer exists in /Users/aaron/repos/c21redwood/c21-backoffice/vendor/troydavisson/phrets/src/Parsers/GetMetadata/System.php:29
Stack trace:
#0 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/troydavisson/phrets/src/Parsers/GetMetadata/System.php(29): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'PHRETS\\Parsers\\...', '/Users/aaron/re...', 29, Array)
troydavisson#1 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/troydavisson/phrets/src/Session.php(244): PHRETS\Parsers\GetMetadata\System->parse(Object(PHRETS\Session), Object(PHRETS\Http\Response), NULL)
troydavisson#2 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/troydavisson/phrets/src/Session.php(153): PHRETS\Session->MakeMetadataRequest('METADATA-SYSTEM', 0, Object(PHRETS\Parsers\GetMetadata\System))
troydavisson#3 /Users/aaron/repos/c21redwood/c21-backoffice/app/Console/Commands/RetsLogin.php(55): PHRETS\Session->GetSystemMetadata()
troydavisson#4 [internal function]: App\Console\Commands\RetsLogin->handle()
troydavisson#5 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
troydavisson#6 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
troydavisson#7 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
troydavisson#8 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/laravel/framework/src/Illuminate/Container/Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
troydavisson#9 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/laravel/framework/src/Illuminate/Console/Command.php(182): Illuminate\Container\Container->call(Array)
troydavisson#10 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/symfony/console/Command/Command.php(264): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
troydavisson#11 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
troydavisson#12 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/symfony/console/Application.php(869): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
troydavisson#13 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/symfony/console/Application.php(223): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\RetsLogin), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
troydavisson#14 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/symfony/console/Application.php(130): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
troydavisson#15 /Users/aaron/repos/c21redwood/c21-backoffice/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
troydavisson#16 /Users/aaron/repos/c21redwood/c21-backoffice/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
troydavisson#17 {main}  

Renaming the property `SYSTEM` to `System` fixes the problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants