Details
-
Type: Improvement
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: 3.6.0
-
Fix Version/s: Short Term
-
Component/s: None
-
Labels:None
-
Epic Link:
Description
When the cron runs to Apply Payments to Open Invoices, a call is made to fetch all clients within each client group via Clients::getAll. Large data sets can cause the memory limit to be exceeded, so we should update this to use an iterator instead.
We can fetch only client IDs via the iterator, then store those in memory rather than all of the client information. The cron action should only need the client ID, and can continue on as-is.
e.g. the iterator
return $this->Record->getStatement();
Since all public model methods are available via the API, it would not make sense to update the Clients model to return an iterator since that would not be usable via the API. It would be better to refactor the models first to create an abstraction that not only performs queries from models, but provides a way to retrieve an iterator and filter the results before returning them from the API. At that point, this cron task colud be updated to fetch that iterator.