allsky icon indicating copy to clipboard operation
allsky copied to clipboard

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/allsky/functions.php on line 186

Open itsgps opened this issue 1 month ago • 4 comments

This occurs in CURRENT, and will be seen in Newer versions of PHP from 8.2.x onwards where the RFC was: "Deprecate dynamic properties and some legacy string interpolation features" The Deprecation is: "{$foo[bar]}" "imagecreatefrom${funcext}"

Specifically for AllSky - The Function on line 186 is: if (function_exists("imagecreatefrom${funcext}") == false)

Suggested fix for this is to change the Function to the following - which is valid also for all versions of PHP from 5.2 Onwards:

if (function_exists("imagecreatefrom{$funcext}") == false)

The Existing Function will be fully deprecated from PHP 9.0 onwards

Basing this requirement on a Recent update to Allsky sites - not sure if it has already been rectified in any recent code changes - in which case this Issue can be closed off.

itsgps avatar Nov 25 '25 03:11 itsgps

Thanks for pointing this out. There are several other files that have ${var} that will also need fixing.

Has {$foo[bar]} been depreciated? If so, what's the fix for it?

Eric

EricClaeys avatar Nov 25 '25 18:11 EricClaeys

@itsgps, I changed the ${var} to {$var} in about a dozen files in the v2025.xx.xx branch, which is our development branch. Would you be willing to see if I missed anything in that branch? Much appreciated. Eric

EricClaeys avatar Nov 25 '25 20:11 EricClaeys

Will give it a look over.

This is the reference in PHP manual - apolgies I didn't get back to you earlier. https://www.php.net/manual/en/migration82.deprecated.php

There are several other references out and about around defining the #[AllowDynamicProperties] attribute as a work-around and that is also referenced in that deprecation page.

for reference I only noticed it when migrating the Remote Web-site from a PHP 8.2.20 server to a New 8.2.29 Docker container...Which theoretically means it was already in the "to be deprecated" list, yet never showed on the Old web-site. So something to consider for others, is to make sure you don't have warning/deprecation suppression enabled in PHP.ini settings, otherwise you miss important information like this.

Ideally in php.ini you should have the following: display_errors = On log_errors = On error_log = /path/to/your/error_log.log Or indeed if not wanting to Show errors - you can set display_errors = off - but you should then be fastidious at checking for errors in logs, and or parse errors to Email notifications, etc.

itsgps avatar Nov 25 '25 22:11 itsgps

@itsgps, Thanks for your help. We can't control the PHP that people run on their remote Websites, and I suspect most users can't either since many use hosted solutions.

EricClaeys avatar Nov 25 '25 23:11 EricClaeys