Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.2 compatibility #2020

Closed
anayrat opened this issue Sep 21, 2023 · 5 comments
Closed

PHP 8.2 compatibility #2020

anayrat opened this issue Sep 21, 2023 · 5 comments
Labels
php compatibility php version support support installation and configuration issues

Comments

@anayrat
Copy link

anayrat commented Sep 21, 2023

Hello,
Does Shaarli is compatible with php 8.2?

I tried to update from an old debian with php 7.3 and shaarli 12.1 to a new one (bookworm) with php 8.2 and shaarli 12.2.
I downloaded 12.2 release, uncompressed it and restored backup data folder. When I try to login, I got this error in the logs:

2023/09/21 12:01:22 [error] 57620#57620: *49 FastCGI sent in stderr: "PHP message: 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; PHP message: 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; PHP message: 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; PHP message: 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; PHP message: 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; PHP message: 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; PHP message: 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; PHP message: 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; PHP message: Return type of Slim\Collection::count() sh

Thanks 🙏

@nodiscc nodiscc self-assigned this Sep 21, 2023
@nodiscc nodiscc added bug it's broken! unconfirmed php compatibility php version support labels Sep 21, 2023
@nodiscc nodiscc added this to the 0.13.0 milestone Sep 21, 2023
@nodiscc nodiscc removed their assignment Sep 21, 2023
@nodiscc
Copy link
Member

nodiscc commented Sep 21, 2023

Hi @anayrat
I cannot reproduce this currently (Debian 12, php-fpm 8.2.7-1~deb12u1, apache, Shaarli 0.12.2).
I have tried both with a fresh installation, and by upgrading a Debian 11/PHP 7.4 -> Debian 12/PHP 8.2.

Can you provide more info about your setup? (web server virtualhost configuration, php-fpm configuration...). Here is mine (very close to https://shaarli.readthedocs.io/en/master/Server-configuration/):

$ cat /etc/apache2/sites-available/shaarli.conf 
<VirtualHost *:80>
    DocumentRoot /var/www/links.example.org
    ServerName links.example.org
    # Redirect all HTTP requests to HTTPS
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>


<VirtualHost *:443>
  DocumentRoot /var/www/links.example.org
  ServerName  links.example.org
  SSLEngine on
  SSLCertificateFile /etc/ssl/certs/links.example.org.crt
  SSLCertificateKeyFile /etc/ssl/private/links.example.org.key
  DocumentRoot /var/www/links.example.org

  <FilesMatch \.php$>
    SetHandler "proxy:unix:/run/php/php8.2-fpm-shaarli.sock|fcgi://localhost"
  </FilesMatch>

  <Directory /var/www/links.example.org>
      # Required for .htaccess support
      AllowOverride All
      Require all granted
      Header always set Content-Security-Policy "script-src 'self' 'unsafe-inline' https://www.youtube.com https://s.ytimg.com; frame-ancestors 'none'"
  </Directory>

  <FilesMatch ".*\.(?!(ico|css|js|gif|jpe?g|png|ttf|oet|woff2?)$)[^\.]*$">
    Require all denied
  </FilesMatch>

  DirectoryIndex index.php

  <Files "index.php">
    Require all granted
  </Files>

  <Directory /var/www/links.example.org/doc/html/>
    DirectoryIndex index.html
    <FilesMatch ".*\.html">
      Require all granted
    </FilesMatch>
  </Directory>

  <FilesMatch "\.(?:ico|css|js|gif|jpe?g|png|ttf|oet|woff2)$">
      # allow client-side caching of static files
      Header set Cache-Control "max-age=2628000, public, must-revalidate, proxy-revalidate"
  </FilesMatch>

  # serve the Shaarli favicon from its custom location
  Alias favicon.ico /var/www/links.example.org/images/favicon.ico
</VirtualHost>
cat /etc/php/8.2/fpm/pool.d/shaarli.conf 
[shaarli]
user = shaarli
group = shaarli
listen = /run/php/php8.2-fpm-shaarli.sock
listen.owner = shaarli
listen.group = www-data
listen.allowed_clients = 127.0.0.1

;;; PROCESS MANAGEMENT ;;;
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.process_idle_timeout = 20s
;pm.max_requests = 500

;;; MONITORING ;;;
;pm.status_path = /status
;ping.path = /ping
;ping.response = pong

;;; LOGGING/DEBUGGING ;;;
;access.log = log/$pool.access.log
;slowlog = log/$pool.log.slow
;request_slowlog_timeout = 0
;request_slowlog_trace_depth = 20
;catch_workers_output = no
;php_flag[display_errors] = off

;;; LIMITS
php_admin_value[max_execution_time] = 30
php_admin_value[max_input_time] = 60
php_admin_value[memory_limit] = 128M
php_admin_value[post_max_size] = 8M
php_admin_value[upload_max_filesize] = 2M
;rlimit_files = 1024
;chroot =
;chdir = /

Also make sure that the recommended PHP extensions are installed. For Debian 12 these are php8.2-gd php8.2-fpm php8.2-curl php8.2-fpm php8.2-mbstring php8.2-intl php8.2-curl php8.2-gettext php8.2-ldap

More importantly, does the application work despite the message?

@nodiscc nodiscc added support installation and configuration issues and removed bug it's broken! unconfirmed labels Sep 21, 2023
@nodiscc nodiscc modified the milestones: 0.13.0, backlog to the future Sep 21, 2023
nodiscc added a commit that referenced this issue Sep 21, 2023
- Tested with php-fpm 8.2.7-1~deb12u1 on Debian 12
- ref. #2020
@anayrat
Copy link
Author

anayrat commented Sep 21, 2023

The app works until I try to login. My configuration is more complex, I use a reverse proxy.
Here is a complete log:

2023/09/21 15:47:43 [error] 59334#59334: *579 FastCGI sent in stderr: "PHP message: 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; PHP message: 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; PHP message: 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; PHP message: 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; PHP message: 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; PHP message: 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; PHP message: 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; PHP message: 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; PHP message: Return type of Slim\Collection::count() s
2023/09/21 15:47:43 [error] 59334#59334: *579 FastCGI sent in stderr: " Passing null to parameter #2 ($string) of type string is deprecated" while reading response header from upstream, client: 192.168.10.24, server: shaarli.xxx.info, request: "GET /login HTTP/1.0", upstream: "fastcgi://unix:/run/php/php8.2-fpm.sock:", host: "shaarli.xxx.info", referrer: "https://shaarli.xxx.info/"

It seems I have all requirements:

 php8.2                            
 php8.2-apcu                       
 php8.2-bz2                        
 php8.2-cli                        
 php8.2-common                     
 php8.2-curl                       
 php8.2-dev                        
 php8.2-fpm                        
 php8.2-gd                         
 php8.2-imagick                    
 php8.2-intl                       
 php8.2-mbstring                   
 php8.2-opcache                    
 php8.2-pgsql                      
 php8.2-readline                   
 php8.2-sqlite3                    
 php8.2-tidy                       
 php8.2-xml                        
 php8.2-zip                        
 php-common                        
 php-composer-ca-bundle            
 php-composer-class-map-generator  
 php-composer-metadata-minifier    
 php-composer-pcre                 
 php-composer-semver               
 php-composer-spdx-licenses        
 php-composer-xdebug-handler       
 php-json-schema                   
 php-pear                          
 php-php-gettext                   
 php-psr-container                 
 php-psr-log                       
 php-react-promise                 
 php-seld-signal-handler           
 php-symfony-console               
 php-symfony-deprecation-contracts 
 php-symfony-filesystem            
 php-symfony-finder                
 php-symfony-process               
 php-symfony-service-contracts     
 php-symfony-string                
 pkg-php-tools                     

Here is my nginx configuration:

server {
    listen       80;
    server_name  shaarli.xxx.info;


    root   /var/www/xxx.info/shaarli;
    index  index.html index.htm index.php;

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|oet|woff2?)$ {
        # cache static assets
        expires    max;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }
    location = /favicon.ico {
        # serve the Shaarli favicon from its custom location
        alias /var/www/shaarli/images/favicon.ico;
    }

    location /doc/html/ {
        default_type "text/html";
        try_files $uri $uri/ $uri.html =404;
    }
    location / {
        # Slim - rewrite URLs & do NOT serve static files through this location
        try_files _ /index.php$is_args$args;
    }
    #proxy_busy_buffers_size   512k;
    #proxy_buffers   4 512k;
    #proxy_buffer_size   256k;
    # rest of the nginx config below #
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass   unix:/run/php/php8.2-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

@anayrat
Copy link
Author

anayrat commented Sep 21, 2023

Hum, I added these lines in my nginx configuration and it works now:

fastcgi_buffers 16 16k; 
fastcgi_buffer_size 32k;

Thought, I still have errors in the logs.

@nodiscc
Copy link
Member

nodiscc commented Sep 21, 2023

I use a reverse proxy.

I also do, but using apache (proxy configuration above).

Shaarli is compatible with php 8.2?

Since this was the original question, yes it does, as you can see.

fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;

These settings are documented here, I don't clearly see how they could be related to the very specific error message you were getting...

Could this be related to some sort of PHP script caching on the server? Can you revert the fastcgi_buffers/fastcgi_buffer_size you made, try to use Shaarli, and tell us if the problem appears again?

(By the way I was unable to reproduce the error message, even with error_reporting = E_ALL in php.ini)

@anayrat
Copy link
Author

anayrat commented Sep 22, 2023

Hello,
I added these lines because I had this error in the logs:

upstream sent too big header while reading response header from upstream

I still have the error (PHP message: Return type of Pimple\Container::offsetExists($id) ) but the app work fine. I will try to take more time to dig it.
Thanks!

@nodiscc nodiscc closed this as completed Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
php compatibility php version support support installation and configuration issues
Projects
None yet
Development

No branches or pull requests

2 participants