Thought it was a PHP 8 issue but looks like it's actually always been a bug maybe. I tweaked the code to reproduce this but in the end I think it happens maybe when you enable report purging but don't keep any periods or so.
Noticed must be this query because it says:
near &<a href='/039'>#039</a>;AND idarchive >= ? AND idarchive < ?&<a href='/039'>#039</a>; at line 3',
I can confirm this solved the errors, many thanks!