Not a bug Fatal Error: syntax error, unexpected 'const' ...

Fethi.dz

Well-known member
Affected version
XF 2.1 / PHP 5.6
Server error log:

Code:
 ErrorException: Fatal Error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) src\vendor\minishlink\web-push\src\WebPush.php:24

Since to xF 2.1 requires PHP 7.1 + to support Push notification then it shouldn't try to send notification if a user enable Push notifications in his account preferences.

To reproduce the error:

I downgrade PHP version from 7.2 to 5.6, when I try to post or react to any content I get the above error.
This happened when the content owner has enabled in his account preferences Push notifications / when I uncheck them the error disappear.
 
In many cases, we don't constant check requirements at run time. We assume that if the requirements were met when enabling (particularly regarding PHP version and PHP components), that they are still met at run time. Therefore, this isn't something we'd inherently consider a bug.

Note that there are potentially some other situations where downgrading PHP may cause certain types of data to be unreadable (for example, it may disable access to a particular type of password hash or change the serialization method for some data and the older PHP version may not know how to handle this). If you do downgrade PHP, you need to be aware of the potential issues it can cause (such as the one demonstrated here).
 
Top Bottom