jelhan / croodle

Croodle is a web application to schedule a date or to do a poll on a general topics.
MIT License
185 stars 24 forks source link

Support PHP 8.2/8.3 #991

Closed shadzik closed 5 months ago

shadzik commented 5 months ago

Croodle doesn't suport PHP 8.2 nor 8.3. It works fine with PHP 7.4 though.

When run on a PHP 8 instance, after creating a poll you'll get a NULL value in your '#/poll/NULL/evaluation?...' URL path. Replacing the NULL part with the actual poll hash from your /data directory doesn't work and the site always shows a generic An unexpected error occured We are sorry. An unexpected error occurred. Please try again later. error.

I can provide more details if needed.

jelhan commented 5 months ago

Tests are run with PHP 8.2 in CI. Need to extend to PHP 8.3.

The error with null may be caused by frontend. Do you have a running instance, which I can play around with?

shadzik commented 5 months ago

@jelhan yes, be my guest - [REDACTED] this is my instance, it currently runs with PHP 8.3

jelhan commented 5 months ago

You have an issue with your PHP configuration. It responses with deprecation notices corrupting the JSON document.

E.g. this is the response when creating a poll:

Deprecated: Return type of Pimple\Container::offsetExists($id) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/pimple/pimple/src/Pimple/Container.php on line 133

Deprecated: Return type of Pimple\Container::offsetGet($id) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/pimple/pimple/src/Pimple/Container.php on line 98

Deprecated: Return type of Pimple\Container::offsetSet($id, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/pimple/pimple/src/Pimple/Container.php on line 79

Deprecated: Return type of Pimple\Container::offsetUnset($id) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/pimple/pimple/src/Pimple/Container.php on line 143

Deprecated: Return type of Slim\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Collection.php on line 112

Deprecated: Return type of Slim\Collection::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Collection.php on line 124

Deprecated: Return type of Slim\Collection::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Collection.php on line 135

Deprecated: Return type of Slim\Collection::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Collection.php on line 145

Deprecated: Return type of Slim\Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Collection.php on line 155

Deprecated: Return type of Slim\Collection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Collection.php on line 165

Deprecated: Return type of Slim\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Collection.php on line 112

Deprecated: Return type of Slim\Collection::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Collection.php on line 124

Deprecated: Return type of Slim\Collection::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Collection.php on line 135

Deprecated: Return type of Slim\Collection::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Collection.php on line 145

Deprecated: Return type of Slim\Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Collection.php on line 155

Deprecated: Return type of Slim\Collection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Collection.php on line 165
{"poll":{"anonymousUser":"{\"iv\":\"\/lE4e2MZoHc\/uWeOGBdzQg==\",\"v\":1,\"iter\":10000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"T\/X9YrMPwX8=\",\"ct\":\"PHH8XCMvAnH96iuBdw==\"}","answers":"{\"iv\":\"1sjc0wVbUKxXNNPq0OWzrg==\",\"v\":1,\"iter\":10000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"T\/X9YrMPwX8=\",\"ct\":\"DKYmmL3OPJxz0Rkigl8kkaHl7SmtBTMuvI+TCZSFh1W9huufD8KbgMY3HlKaZY1CVv5irWUeUp7+O8ZGqva5j\/HEEGisRYrgivGHOJZlca3jO27+SrQmKw2Puoy2AEJP3ZOatbbt4fusks+h5\/bvnxg7cfNCbD8pa4yWxLHvTH586duwUUgzWqp4HFigvpLf5Ti0qJ58csIifUtT0wDqMu8SduBYOEDaFWs3Jh5ZGaqRjL6qSZLKqG4FWXXjIy0sK1bGP2xNc31hFvv3FjzdqXq3SQUedCdfYnB5edzx0Ng7Si4cpg==\"}","answerType":"{\"iv\":\"YJUlKldn\/uM+AjHfstRODA==\",\"v\":1,\"iter\":10000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"T\/X9YrMPwX8=\",\"ct\":\"3Rvh9yWVrw5pqQvQ9vBJ\"}","creationDate":"{\"iv\":\"CYmmm81wuRcwnOqX69kbTA==\",\"v\":1,\"iter\":10000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"T\/X9YrMPwX8=\",\"ct\":\"9AuZ9Yj7ufGpeSfmXpomM6\/MCoLMHIu0TfrVJE+jTCej9Q==\"}","description":"{\"iv\":\"9kDLgIX0c6FG\/gM3dEfqBw==\",\"v\":1,\"iter\":10000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"T\/X9YrMPwX8=\",\"ct\":\"wl0+GSvJTGEiew==\"}","expirationDate":"{\"iv\":\"fctKZBP8tfpnVu6BKlXKPg==\",\"v\":1,\"iter\":10000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"T\/X9YrMPwX8=\",\"ct\":\"Jt9ZvXaBxyBVawdxqUyIPrccDehYp4w7z\/c60NqIE6C00g==\"}","forceAnswer":"{\"iv\":\"dOIpGD505yeuD1Gld2QpDA==\",\"v\":1,\"iter\":10000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"T\/X9YrMPwX8=\",\"ct\":\"\/zCUVbVIhfnifaXM\"}","options":"{\"iv\":\"8kqPA5skRcchcOAfADJ16w==\",\"v\":1,\"iter\":10000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"T\/X9YrMPwX8=\",\"ct\":\"qQtlcoe7oHwCRgMenvGu0wTRt1Z4PoOQxGWPmQ2GV73S4\/5ANabAjPugdlW\/oNlCJu\/Cz0MdefUIsfQVCnnS4FCJhVoCL93NWjCwNTAW\"}","pollType":"{\"iv\":\"vWiCYHvaPuC8OOtG3vgEng==\",\"v\":1,\"iter\":10000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"T\/X9YrMPwX8=\",\"ct\":\"XNIeFZW+wTEF4Pv34QDUEDt7Kw==\"}","timezone":"{\"iv\":\"gMlkhuN91aIAfDs6IX0RBw==\",\"v\":1,\"iter\":10000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"T\/X9YrMPwX8=\",\"ct\":\"A2\/bUOiuabFVdee2\"}","title":"{\"iv\":\"GAH86rNv640CMe7f4Ak7Fg==\",\"v\":1,\"iter\":10000,\"ks\":128,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"T\/X9YrMPwX8=\",\"ct\":\"BrdGL0jpWu1YkaugAOC5CMO46HaCwGBz+9Uy\"}","version":"0.6.2+fff213a8","id":"ckUW453mUx","users":[]}}
Deprecated: preg_replace_callback(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /home/users/ltcherren/public_html/croodle/api/vendor/slim/slim/Slim/Http/Uri.php on line 716

Additionally it seems to send wrong HTTP header. But that is likely a side effect to the deprecation warnings being included in the response.

For security reasons log output - regardless if deprecation or error stack trace - should not be send to end-users. This could leak information about server setup revealing potential attack vendors.

Likely the display_errors configuration option is set wrongly for a production system.

shadzik commented 5 months ago

Hey,

yes, display_errors was on because I was also debugging this instance. It's set to off now. But how can I fix those deprecation errors? The instance you're testing is a bit older, self-compiled, so I thought it might be that... but I've also installed a newer version, right from this repository (the release version) and that one is also online at [REDACTED] - but the problem is the same.

Any ideas?

shadzik commented 5 months ago

I'm sorry, @jelhan you're totally right! :) Just tested it and it already works after disabling display_errors. Phew!

Many thanks! You've saved my day. Apparently I forgot to disable that setting when playing around with another software also hosted at this adress. Thanks again!

jelhan commented 5 months ago

But how can I fix those deprecation errors?

You don't need to. You can just ignore them. I will take care of fixing them before adding support for PHP 9.

I've also installed a newer version, right from this repository (the release version) and that one is also online at https://ltc-herren.one/croodle2/ - but the problem is the same.

Can you please share to reproduce for this instance? I was doing some very basic testing. And all seem to work fine.

shadzik commented 5 months ago

@jelhan please see my comment above - everything seems to work just fine now. Again, I can't thank you enough :) I really appreciate it!

jelhan commented 5 months ago

I'm glad that I was able to help. Motivating to see that a sport club in Lichtenberg considers Croodle!

shadzik commented 5 months ago

Yes! We've been using Croodle for around 2,5 years and were very happy that there's an Open Source alternative to Doodle ;) And now that our instance works again we can start polls as to who can play when :) I personally always recommend Croodle, so yes, we use it a lot ;)

MCMicS commented 4 months ago

HAd same issue in my test I used a Dockerfile with php 8.2 and got the same error After downgrading to 7.4 it works again

Small sample

#FROM php:8.2-apache
FROM php:7.4-apache

# Use a release tag from https://github.com/jelhan/croodle/releases.
ENV CROODLE_VERSION v0.7.0

WORKDIR /var/www/html

# Grab and expand release files.
RUN rm -rf * \
  && curl -SL -o croodle.tgz https://github.com/jelhan/croodle/releases/download/${CROODLE_VERSION}/croodle-${CROODLE_VERSION}.tar.gz \
  && tar zxf croodle.tgz \
  && rm croodle.tgz \
  && chmod 777 data

I don't know 100% why this happens on the image but maybe the same cause. I can also file a new issue if wanted.

Create tool BTW 👍🏻