PHP Deprecated: str_ireplace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /var/www/html/app/bundles/PageBundle/EventListener/BuilderSubscriber.php on line 339

Your software
My Mautic version is: 5.0.4
My PHP version is: 8.1.27
My Database type and version is: 10.6.16-MariaDB-0ubuntu0.22.04.1

Your problem
My problem is:
500 Internal Server Error, reported as this in the PHP error log when I try to access the preference center by clicking the {unsubscribe_text} link in an email.

https://links.m.example.com/?ref=… > https://m.example.com/email/unsubscribe/661

These errors are showing in the log:
PHP Deprecated: str_ireplace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /var/www/html/app/bundles/PageBundle/EventListener/BuilderSubscriber.php on line 339

Steps I have tried to fix the problem:

Looking at the code, it seems the only possible way how to get this 500 error is:

  1. your production error level isn’t set correctly. This should be logged, not thrown as a 500 error.
  2. You use {pagemetadescription} token and the description is empty.

Can you confirm?

Actually, the point 2 is wrong. It must be some other reason but I don’t see it in the code just by reading it.

Correct about the reporting level. Forgot to restore it to defaults: E_ALL & ~E_DEPRECATED & ~E_STRICT

Done now.

The preference page worked fine until Friday or so. I don’t know what could have caused this error.

As an aside: Earlier, I added a feedback form to the preference center which resulted in the page using the same page template twice. That somehow led to the preference page and the form both being wrapped with the custom page template that I’ve made and which is branded. So I assigned the Blank theme to the preference center landing page. That fixed it.

Error reporting is set to the default now, as is evident in Mautic:

The deprecated error should not lead to a 500 server error. Something else does.

I ran cache:clear and cache:warmup and the error went away…

I put an uptime monitor on that page so I get notified in case the error comes back.

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.