shaarli / Shaarli

The personal, minimalist, super-fast, database free, bookmarking service - community repo
https://shaarli.readthedocs.io/
Other
3.41k stars 291 forks source link

PHP deprecations/errors with PHP 8.2 #1935

Closed AlphaJack closed 10 months ago

AlphaJack commented 1 year ago

By updating shaarli to the latest commit (number: 2318, hash: ab16f6a8) from the previous commit it has been built (number: 2269, hash: 51603fe2) I am getting the following issues:

2023/01/25 03:22:02 [error] 1122280#1122280: *2855022 FastCGI sent in stderr: "8934cf9db5d80e.rtpl.php on line 123PHP message: PHP Deprecated
:  Function strftime() is deprecated in /var/lib/shaarli/tmp/linklist.025e4ef3c23e9ff6918934cf9db5d80e.rtpl.php on line 123 [...]

2023/01/25 03:22:02 [error] 1122280#1122280: *2855022 upstream sent too big header while reading response header from upstream, client: 1.1.1.1, server: links.example.org, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/php-fpm.sock:", host: "links.example.org"

2023/01/25 03:22:05 [error] 1122280#1122280: *2855022 FastCGI sent in stderr: "PHP message: PHP 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 /usr/share/webapps/shaarli/vendor/pimple/pimple/src/Pimple/Container.php on line 133PHP
 message: PHP Deprecated:  Return type of Pimple\Container::offsetGet($id) should either be compatible with ArrayAccess::offsetGet(mixed $off
set): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/webapps/shaarli/vendor
/pimple/pimple/src/Pimple/Container.php on line 98PHP message: PHP Deprecated:  Return type of Pimple\Container::offsetSet($id, $value) shoul
d either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be us
ed to temporarily suppress the notice in /usr/share/webapps/shaarli/vendor/pimple/pimple/src/Pimple/Container.php on line 79PHP message: PHP 
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 /usr/share/webapps/shaarli/vendor/pimple/pim
ple/src/Pimple/Container.php on line 143PHP message: PHP Deprecated:  Return type of Slim\Collection::offsetExists($key) should either be com
patible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress
 the notice in /usr/share/webapps/shaarli/vendor/slim/slim/Slim/Collection.php on line 112PHP message: PHP Deprecated:  Return type of Slim\C
ollection::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] att
ribute should be used to temporarily suppress the notice in /usr/share/we

2023/01/25 03:25:49 [error] 1122280#1122280: *2855104 FastCGI sent in stderr: "er be compatible with ArrayAccess::offsetSet(mixed $offset, mi
xed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/webapps/shaarli/
vendor/slim/slim/Slim/Collection.php on line 135PHP message: PHP 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 su
ppress the notice in /usr/share/webapps/shaarli/vendor/slim/slim/Slim/Collection.php on line 145PHP message: PHP Deprecated:  Return type of 
Slim\Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used t
o temporarily suppress the notice in /usr/share/webapps/shaarli/vendor/slim/slim/Slim/Collection.php on line 155PHP message: PHP Deprecated: 
 Return type of Slim\Collection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\Retu
rnTypeWillChange] attribute should be used to temporarily suppress the notice in /usr/share/webapps/shaarli/vendor/slim/slim/Slim/Collection.
php on line 165PHP message: PHP Deprecated:  preg_replace_callback(): Passing null to parameter #3 ($subject) of type array|string is depreca
ted in /usr/share/webapps/shaarli/vendor/slim/slim/Slim/Http/Uri.php on line 716PHP message: PHP Deprecated:  Creation of dynamic property Sh
aarli\Container\ShaarliContainer::$basePath is deprecated in /usr/share/webapps/shaarli/application/front/ShaarliMiddleware.php on line 113PH
P message: PHP Deprecated:  explode(): Passing null to parameter #2 ($string) of type string is deprecated in /usr/share/webapps/shaarli/vend
or/slim/slim/Slim/Http/Request.php on line 1019PHP message: PHP Deprecated:  explode(): Passing null to parameter #2 ($string) of type string
 is deprecated in /usr/share/webapps/shaarli/vendor/slim/slim/Slim/Http/R

2023/01/25 03:25:49 [error] 1122280#1122280: *2855104 FastCGI sent in stderr: "8934cf9db5d80e.rtpl.php on line 123PHP message: PHP Deprecated
:  Function strftime() is deprecated in /var/lib/shaarli/tmp/linklist.025e4ef3c23e9ff6918934cf9db5d80e.rtpl.php on line 123 [...]

If I rebuild shaarli against the previous commit, everything works fine, even with PHP 8.2

nodiscc commented 1 year ago

Thanks for reporting this. I will try to reproduce it. This is the diff between 51603fe and master: https://github.com/shaarli/Shaarli/compare/51603fe265b796a4f7a6037b44518988addfcd46...master (49 commits).

Which Installation method did you use? (from source + composer? Docker). More details on installation steps you performed are welcome.

AlphaJack commented 1 year ago

Thank you, I installed from source, you can find the steps here: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=shaarli-git

PHP enabled extensions:

extension=gd
extension=gettext
extension=intl
extension=ldap

PHP-FPM pool config:

[www]
user = http
group = http
listen = /run/php-fpm/php-fpm.sock
listen.owner = http
listen.group = http
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

Ideally I would like to install Shaarli in a dedicate container, but unfortunately the Dockerhub image does not ship in arm64 architecture (see #1496)

nodiscc commented 1 year ago

Function strftime() is deprecated

This is expected since strftime() is deprecated as of PHP 8.1.0 (https://www.php.net/manual/en/function.strftime.php) and is still used in multiple places (it was already present in 51603fe265b796a4f7a6037b44518988addfcd46)

~/GIT/Shaarli (master $=)$ git grep -n strftime
application/Utils.php:347:    return strftime('%B', $date->getTimestamp());
tpl/vintage/daily.html:41:        {function="strftime('%A %d, %B %Y', $day)"}
tpl/vintage/daily.html:61:                                <a href="{$base_path}/shaare/{$value.shorturl}">{function="strftime('%c', $link.timestamp)"}</a>

everything works fine, even with PHP 8.2

Are you sure it does? This deprecation warning should be present with PHP 8.1 and 8.2, regardless of Shaarli version.

(These warnings should not prevent Shaarli from working correctly. In the mean time, if you want to get rid of the warnings, you can either stick with PHP 8.0 which is supported until November 2023 or disable reporting of deprecation warnings in your PHP configuration.)

AlphaJack commented 1 year ago

Are you sure it does? This deprecation warning should be present with PHP 8.1 and 8.2, regardless of Shaarli version.

I get this:

PHP 8.1 PHP 8.2
Shaarli 2269 Warning Warning
Shaarli 2318 Not tried Error

Only with "Error" the website is broken

nodiscc commented 11 months ago

@AlphaJack do you still have this problem with the latest release?

I am running Shaarli v0.12.2 on PHP 8.2.7-1~deb12u1 without problems.

nodiscc commented 10 months ago

I can't reproduce this either with the setup mentioned above (deployment from release zip + PHP 8.2 on Debian), or with the latest docker image which uses PHP 8.2.

Feel free to reopen this issue if the problem is still present.