Troubleshooting a Call to a member function isRecurring() on null Error

Symptom

After applying the 7.10.2 update, an Oops fatal PHP error can occurr in certain circumstances when interacting with invoices:

exception 'Whoops\Exception\ErrorException' with message 'Call to a member function isRecurring() on null' in /path/to/whmcs/vendor/whmcs/whmcs-foundation/lib/Billing/Invoice.php:0
Click to copy

Cause

This occurs when viewing, sending a reminder email or attempting  capture on an invoice containing a line item related to a deleted  service.

Hotfix

A hotfix has been created for 7.10.2 only to better handle installations with missing data:

https://whmcs.community/files/file/133-core-14659-call-to-a-member-function-isrecurring-on-null/