Custom Task shows as running forever on "error"; Unable to use DateImmutable?

I have noticed 2 things creating a custom Task.

  1. When there is some kind of “error” condition (error as interpretted by Xibo it seems), the task stays listed as “running” and no error output or anything helpful to debug what happened shows anywhere (ex. PHP logs are clean).

  2. I painstakingly commented out most of my code, re-enabling line by line until I ran into the task not showing as completing. I got to this line below, instancing an object of DateImmutable as the first culprit.

$dt = new DateTimeImmutable($time2);

And $time2 is defined right above it (and works in this code):

$time2 = $entries[0]->pubDate;

No idea why DateImmutable wouldn’t work. On the same server, I created a test php file using the same code outside of the Xibo task class and it works fine, NO php errors or anything. What is going on? This is very frustrating, combined with the almost complete lack of documentation on even how to build a task class file aside from searching these very forums.

I hope someone is able to figure this out. I notice this behavior both on 2.x and 3.x versions so far. Using the official Xibo docker.

edit: Adding the full class file. The file given is line 115 in the checkContent() function.

https://pastebin.com/jSGjVJpd