Closed gjerdery closed 4 years ago
Hi there, thanks for giving this a try and for reporting this issue. So far I've only tested with my library's data so this is a great opportunity to test & smooth out any problems I wouldn't have encountered on my own. Is line 156 the only line of code that triggers that error, or are there other lines of code where it's happening as well? If there's an error in that line only, what will probably happen is that order items will be loaded but without the title of the book (you'd only get the author, OCLC number, etc).. would definitely want to fix it, though it might not prevent you from doing further testing (your books just wouldn't have any titles until the problem is fixed).
To fix the issue, it might help me to see an example orderItem that is getting imported from your OCLC data, to see whether there's anything about your library's order data that might throw off this importing process. Would you be willing to insert the following line of code just above line 156? var_dump($orderItem->resource); Then next time you try and load orders, it will print to your screen details of the orderItem objects. If you send me the details of a couple example orderItem objects, I might be able to verify whether it looks OK and/or adjust the code to resolve the error.
Many of the "count()" calls in the autoloaditems function are throwing this error - I can't tell if the same orderitem is generating multiple errors, or if they are all coming from distinct items. I'll do a var_dump tomorrow and share the results.
Here is an example of a var dump from the autoLoadItems function:
object(stdClass)#624 (4) { ["worldcatResource"]=> object(stdClass)#320 (9) { ["title"]=> string(22) "The cmdty yearbook ..." ["materialType"]=> string(4) "JRNL" ["author"]=> array(1) { [0]=> string(15) "Barchart (Firm)" } ["edition"]=> string(0) "" ["isbn"]=> array(0) { } ["issn"]=> array(1) { [0]=> string(9) "2688-7673" } ["oclcNumber"]=> string(10) "1108655034" ["publisher"]=> string(47) "Chicago, Illinois : Barchart.com, Inc., [2019]-" ["year"]=> string(4) "2019" } ["kbwcCollectionResource"]=> NULL ["kbwcEntryResource"]=> NULL ["localResource"]=> NULL }
For this item, the "count()" error message previously mentioned appeared in relation to the if tests for title, materialType, oclcNumber, and then for 4 of the copyConfigs elements.
It seems like count() is expecting an array, but will throw the warning and still return 1. Would testing on "isset" be appropriate here?
I see that there are a few other errors cropping up related to this object, but I think I'll add separate issues for them.
Ah, I think you got it. I'm not quite sure why my version of PHP was not giving me the same error when using count(), but I think more appropriate might be !empty() to test whether the element exists and is not empty. I will test that right now and update the repo if it works as intended.
It could be that my server is configured with error reporting at E_ALL, or E_WARNING, and yours is set to E_ERROR. I do see that none of these are fatal errors.
Just confirming the !empty() test works for me too.
Hi Jared, I'm attempting to set this up for the first time, and am encountering the following warning repeatedly as I attempt to load. Is this something to be concerned about?
`A PHP Error was encountered Severity: Warning
Message: count(): Parameter must be an array or an object that implements Countable
Filename: controllers/Bookfeed.php
Line Number: 156
Backtrace:
File: /var/www/html/wmsNewBooks/application/controllers/Bookfeed.php Line: 156 Function: _error_handler
File: /var/www/html/wmsNewBooks/application/controllers/Bookfeed.php Line: 85 Function: autoLoadItems
File: /var/www/html/wmsNewBooks/index.php Line: 315 Function: require_once`