Error with PHP 8.5

I went to check to see if my BackLight software was up to date just now. When I clicked on the Modules link, I received this message:

Something went wrong
The predefined locally scoped $http_response_header variable is deprecated, call http_get_last_response_headers() instead

Setting it back to PHP 8.4 made this go away, and I was able to determine that everything is up to date.

Paul

which version of Backlight are you using? BL 6 should be compatible with php 8.5 but if it isn’t, @Ben will want to know.

Hi @kolohe280, thanks for raising this. Backlight 6 strives to be compatible with PHP 8.5 - it’s updated according to the documentation and I run 8.5 for my development.
I’ll look into this to see what might have been missed.

1 Like

Should have mentioned that. BL6.

Hi @kolohe280, are you still able to use the Backlight Modules page, or does this error prevent it from loading? If you are able to, then a simple update from us should be able to fix it without you needing to manually update and re-run the installer.

OK, I did a little looking around and here’s what I found. I’m running on IONOS, btw.

If I set this domain to PHP 8.5 (they are running 8.5.2 according to phpinfo) the module page loads but does not populate. It works fine on 8.4. phpinfo shows that curl is enabled. So, I should be able to install a fix while on 8.4, switch it to 8.5, and test.

from php doc:
$http_response_header

(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)
$http_response_header — HTTP response headers

Warning
This feature has been DEPRECATED as of PHP 8.5.0. Relying on this feature is highly discouraged.
Use http_get_last_response_headers() instead.

Hi @kolohe280, thanks for checking. We’ve just released an update that addresses this and a few other deprecated functions in PHP 8.5.

If you’re able to switch back to 8.4, upgrade and then back to 8.5 then that would be great. Can you also confirm that the issue is no longer there once you’ve upgraded and are on 8.5?

I will need to provide separate advice for other users if they are unable to temporarily change back to an older version.

Hi, Ben,

I ran the upgrade an 8.4. It was successful but when I switched to 8.5 the error is still there.

I noticed that when I switched from 8.5 back to 8.4 the error appeared there until I cleared the template cache. I have tried doing that on 8.5, but it did not remedy the situation.

I’m seeing something similar.
On my test site, I updated php from 8.2 to 8.5.2 and the site looked fine and I had access to Backlight.
Backlight was running 6.4.2.
I updated Backlight to 6.4.3 and got this error:

Hi @kolohe280 and @rod_barbee, thanks for letting me know. It’s not meant to be like this. Is there a line number that’s being reported? Can I also confirm the page you’re on? Is this just by visiting the Backlight modules page without further action?

I feel that the behaviour of PHP has changed. That it’s reporting issues with lines of code that exist even if those lines of code are not executed. The approach I took, which I’ve done without issue before, was to have a version check: anything PHP 8.0 or above would use the new approach, anything below PHP 8 would use the old. (The new method is only available for PHP 8.0 or above).

That is indeed what’s happening and unfortunately it didn’t come up in my testing. I will need to find another solution.

I looked on my iPad (Safari) and the error wasn’t showing. Went back to my PC (Firefox) and refreshed the page. Error is no longer showing.

That’s interesting. I can no longer suppress it on my end on PHP 8.5. Because the error comes up without the line of code being run, even temporarily turning off deprecated warnings before the line doesn’t work. I can’t think of any way around this other than disabling these warnings entirely, which isn’t great - we’ve always had the philosophy of reporting all issues to help us with the quality of our code.

I’m on page /backlight/admin/list_modules/ when it happens (I deleted my domain from that). No line number is mentioned.

Sounds like you’ve figured out what’s going on. PHP seems to be a moving target on a lot of things. Good luck finding a fix!

Hi @kolohe280, thanks! We’ve release a further update that addresses this. Can you try updating your Backlight Modules and let me know whether the error has disappeared in Backlight 8.5?

This has taken some nutting out. It appears that $http_response_header is handled in a special way by PHP, so this looks to be a unique scenario that is different from the other work done to handle deprecation.

I can now access the modules page with PHP 8.5.

Thanks for taking care of that. I have always been impressed with how well Backlight is supported and appreciate the work you guys do.

Hi @kolohe280, thanks for confirming and for the kind words!

I downloaded the source code for PHP itself and there’s actually a check for this one variable in the code compiler that throws this message. That explains why it was coming up despite extra code checks I put in place to work around it.

1 Like