sal0max / grav-plugin-shortcode-gallery-plusplus

A Shortcode extension to add sweet galleries with a lightbox to your Grav website.
MIT License
33 stars 8 forks source link

PHP Parse error: syntax error, unexpected '?' #27

Closed sal0max closed 2 years ago

sal0max commented 2 years ago

Received this one per mail:

After update shortcode-gallery-plusplus 1.2.1 > 1.4 I got the following error:

[Thu May 05 17:27:15.751955 2022] [php7:error] [pid 26888] [client 84.80.23.178:55825] PHP Parse error: syntax error, unexpected '?', expecting function (T_FUNCTION) or const (T_CONST) in /var/www/html2/grav/user/plugins/shortcode-gallery-plusplus/shortcode-gallery-plusplus.php on line 15

My grav website and admin-page are not working any more. the only solution was to remove plugin by CLI and reinstal the old plugin (from backup)


The code in question here is this line from the merged pull request #25 from @Sailoriae:

private ?Page $currentPage = null;

The error message indicates, that the ?, which is a Nullable Type hint and which was introduced in PHP 7.1, is wrong.

My guess: The email author uses PHP < 7.1, which causes this error. And that is odd. This plugin states, that it needs at least Grav 1.6, and Grav 1.6 needs at least PHP 7.1.3.

Strong indication that PHP7 is used: [php7:error] in the error message. ;)

So, tldr;: Author needs to provide more information. I'll keep this issue updated.

ghost commented 2 years ago

Hello ! ^^ PHP 7.0 has reached EOL 3 years ago, and Grav 1.7 requires PHP 7.3. It's maybe time to upgrade ! 😆 However, if you wish to support old versions, you can just remove the typing of the $currentPage attribute.

private $currentPage = null;

Have a nice day ! ^^

PS : Even Grav 1.6 requires PHP 7.1 !

gjo55 commented 2 years ago

Hello I reported this Isue: Grav-version: 1.7.33 PHP-version 7.3.33 Install was done by admin-plugin Please chck the fact before making jokes

Server is running Ubuntu 18.04+Apache

ghost commented 2 years ago

You should have given the facts before lecturing me about not checking the facts. Especially since I was just reacting to @sal0max's deduction about the PHP version. Anyway, now that we have the facts, we can avoid wasting hours and focus our search : Typed properties were introduced in PHP 7.4, while nullable types were introduced in PHP 7.1. So, @sal0max, you should add a commit removing the type of the $currentPage property because Grav 1.7 supports PHP 7.3.

gjo55 commented 2 years ago

Hello, I will update to PHP-7.4 soon. After that i will install the shortcode-gallery-plusplus 1.4 plugin again and let you know the result . (It was not mine intention to give any lecturing !!)

Thanks for the support

ghost commented 2 years ago

In theory, this plugin should support PHP 7.3 since Grav also supports it. So thank you for your report ! ^^

sal0max commented 2 years ago

Thanks a lot for your help, @Sailoriae!

Done in 01db1836fb5a7bc929659b87320d75de0f46dde7 Implemented and released in version 1.4.1.