Bug in code crashed site
recently my site had a short downtime. After investigating this with my dev we found a bug in the code and a possible fix. Sharing it here:
If you feel this is a good fix I'd appreciate if you can add this to your next update.