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

Possible bug in Server.php #11

Closed
yakovsh opened this issue Jan 25, 2023 · 0 comments
Closed

Possible bug in Server.php #11

yakovsh opened this issue Jan 25, 2023 · 0 comments
Assignees
Labels

Comments

@yakovsh
Copy link

yakovsh commented Jan 25, 2023

Getting the following error with PHP 8.2 and the following request:
?verb=ListRecords&metadataPrefix=oai_dc&from=2023-01-15T00:00:00Z&until=2023-01-25T23:59:59Z

The error is:

stderr: Stack trace:
stderr: #0 /oai/Classes/Server.php(292): array_sum(false)
stderr: #1 /oai/Classes/Server.php(187): OCC\\OAI2\\Server->checkDateFormat('2023-01-15T00:0...')
stderr: #2 [internal function]: OCC\\OAI2\\Server->ListRecords()
stderr: #3 /oai/Classes/Server.php(56): call_user_func(Array)
stderr: #4 /oai/index.php(73): OCC\\OAI2\\Server->__construct('...', Array, Array, Array, Array)
stderr: #5 {main}
stderr:   thrown in /oai/Classes/Server.php on line 292
stderr: PHP Fatal error:  Uncaught TypeError: array_sum(): Argument #1 ($array) must be of type array, bool given in /oai/Classes/Server.php:292

I looked at the code in Server.php, line 292 here:
https://github.com/opencultureconsulting/oai_pmh/blob/master/Classes/Server.php#L292

 return ($datetime !== false) && !array_sum($datetime->getLastErrors());

The docs for "getLastErrors()" say that in case there are no errors a boolean is returned:
https://www.php.net/manual/en/datetime.getlasterrors.php

Returns array containing info about warnings and errors, or false if there are neither warnings nor errors.

I changed my copy of the code as follows and it is working now:

return ($datetime !== false) && ($datetime->getLastErrors() == false);

I can provide a pull request but I am not that familiar with PHP so I am not sure if this is a real bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants