nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
26.96k stars 4.02k forks source link

Support PHP8.1 #29287

Closed ChristophWurst closed 2 years ago

ChristophWurst commented 2 years ago

According to https://php.watch/news/2021/03/php81-release-date PHP8.1 will be released by end of next month. That will mean the release happens somewhere around the release of Nextcloud 23 and we can assume that the early adopters will soon update their systems and find out Nextcloud 23 doesn't support 8.1. Ref https://github.com/nextcloud/server/blob/822623109f4f4b3252c04a5c0ccf6757a882e771/lib/versioncheck.php#L36-L42.

As far as I know php8.1 is "just" a minor release but some libs/code have to be adjusted. We'll have to decide whether to look into this for 23, 23.1 or 24.

Potential breaking changes

cc @AndyScherzinger @juliushaertl @nickvergessen @skjnldsv

txt-file commented 2 years ago

This is not an Arch Linux Support forum. This is an issue tracking system for nextcloud.

Please move questions and help for administration of Linux distributions to the proper Linux distributions user bulletin board.

CapSel commented 2 years ago

Archlinux users please go complain there: https://bugs.archlinux.org/task/73452 (btw I use Archlinux)

dvzrv commented 2 years ago

No, but a non functional NextCloud instance is an issue no matter what distro used. Spamming a bunch of relevant posts from people trying to help out with thumbs down is pretty rude IMO.

@zynexiz This is an upstream issue tracker for the nextcloud server software. The feature request and bug report templates for tickets make its scope very clear.

I would kindly ask all Arch Linux users to use the Arch Linux forums, mailing lists or the #archlinux channel on libera.chat, as this issue tracker is not the place to discuss issues with your installation.This ticket in particular is the place to discuss how to ensure support for php 8.1 in the current code base, not how to run it on your distribution (I'm packaging nextcloud for Arch Linux btw). Not complying with the purpose of this issue tracker in general and this ticket in particular is in fact rude towards the developers of this software that made it quite clear when official support for php 8.1 will be added (see https://github.com/nextcloud/server/issues/29287#issuecomment-1018903637 and https://github.com/nextcloud/server/issues/29287#issuecomment-1019210570 for a timeline).

zynexiz commented 2 years ago

@dvzrv Sorry for that, didn't mean to offend anyone just tried helping out those with a broken installation.

nettybun commented 2 years ago

I'll add that a common pitfall into this mess could be the Nextcloud Updater itself. I've been running 22.2.3 and went to Admin > Overview to run the update but it says "Version 22.2.3. Nextcloud is at latest version". I know I've upgrade other servers to 23. Something must be wrong. It's reasonable as a sysadmin (of any distro!) to think the PHP version might be preventing the upgrade. I also checked with php occ update:check and php occ upgrade - says 22.2.3 is latest.

So. I update to PHP 8.1.

22.3.0 then tells me "This version of Nextcloud is not compatible with > PHP 8.0."

Fine, I'll manually update to 23, using tar -xjvf. Still the same error.

What I'm saying is Nextcloud Updater could do a lot for people to help them understand why they're being held back versions, rather than letting them debug for themselves since that can lead down the wrong path...


Thanks for all the amazing work you do as developers and maintainers, I know this is a complex problem and I'm grateful that it's being looked at! Just trying to suggest a way that Nextcloud could prevent people from breaking installations, since it seems to cause a wave of comments/posts.

Tyler-2 commented 2 years ago

Ouch. I've got two instances down. Wish Debian made it a touch easier to downgrade php and all of its modules.

nursoda commented 2 years ago

How do WordPress and similar projects manage to support new PHP versions once a new PHP version is officially released? And why is it that Nextcloud cannot? Shouldn't it have been a priority to actually have PHP 8.1 support in NC23 as it was clear that PHP 8.1 would be released while NC23 is "latest stable" and NC24 would not be available for several months?

And, yes, apart from that Linux distros should (and partly do) circumvent such incompatibilities for "slower projects", or at least discuss solutions. Given a distro's nature, the focus there is to make the distro's nextcloud package work. In practice, there are quite some native NC installations that cannot be helped by patching but only by either wait for the slowest to-be-supported package (using PHP) or by providing version-numbered package-sets (which is a lot of extra work).

DjSlash commented 2 years ago

Edit: I realised this wasn't the place to add solutions for each distro, sorry for that. Instead I made a topic on the support forum.

GivouDev commented 2 years ago

Yeah, i dont want to complain because i mean its free software and nextcloud is freaking awesome but today a had also the mess on arch. I upgraded NextCloud via der Updater and run pacman -Syu after this....yeah and my installation of course broke...so i needed to downgrade to php-8.0.14 and then downgrade about 10 modules of php to older version which supports php 8.0.

I just hope that NextCloud has a compatible version by the next time I update my server :)

doucettom commented 2 years ago

Just following. I've installed PHP 8.0 and used pecl in the meantime so all extensions works but it is still a workaround. (Ubuntu Server 22.04)

gelo2002 commented 2 years ago

I didn't see any info on this in previous comments, but the cron job is also broken due to newer PHP version. It gives me such error when trying to run cron command: This version of Nextcloud is not compatible with > PHP 8.0.<br/>You are currently running 8.1.2.

bcutter commented 2 years ago

Have a look at https://github.com/nextcloud/server/issues/29287#issuecomment-1014567488

Just downgrade/avoid 8.1, sit down and wait. That's what we need to do for now - and it works fine ;-)

gelo2002 commented 2 years ago

Have a look at #29287 (comment)

Just downgrade/avoid 8.1, sit down and wait. That's what we need to do for now - and it works fine ;-)

Well... I'd love to downgrade, but I have another applications using php8.1 Question is, if even there will be next NC release supporting php8.1, but do to current version does not support it, there might be deadlock by upgrade, when current NC will not upgrade due to php8.1...

Wow, that was rather overly complex sentence I produced...

ambraspace commented 2 years ago

As many of you know, Arch Linux packagers added some patches to NC23 to force it to run with PHP 8.1. However, there's a problem with UTF-8 characters in contact names and file names.

I'm guessing it's because of this change from PHP 8.0 to PHP 8.1:

htmlspecialchars(), htmlentities(), htmlspecialchars_decode(), html_entity_decode(), and get_html_translation_table() now use ENT_QUOTES | ENT_SUBSTITUTE rather than ENT_COMPAT by default. This means that ' is escaped to ' while previously nothing was done. Additionally, malformed UTF-8 will be replaced by a Unicode substitution character, instead of resulting in an empty string.

For example, if you try to create txt file named 'šđčćž', you will first get an error message, but the file will be created. However, you won't be able to delete it. When you choose to delete it, it will behave as it was deleted, but when you refresh the page it will be there.

So, this happens with NC23+PHP8.1, but not with NC23+PHP8.0.

I'm writing just to draw attention to this problem so that developers can make test case (if there isn't one already).

C0rn3j commented 2 years ago

occ scan is also broken.

I wish NC was tested against development PHP releases like other projects are, so that 2 months after a stable release we wouldn't be having type conversion errors breaking major functionality.

[0] # /usr/bin/runuser -u nextcloud -- /usr/bin/php /usr/share/webapps/nextcloud/occ files:scan --all
...
In Scan.php line 293:

  Implicit conversion from float 0.15 to int loses precision                                                          
return sprintf('%02d:%02d:%02d', ($secs / 3600), ($secs / 60 % 60), $secs % 60);
smirkybg commented 2 years ago

Changed the line to:

return sprintf('%02d:%02d:%02d', ($secs / 3600), ((int)($secs / 60) % 60), $secs % 60);

It's good enough for the time being, until an official fix comes along.

doucettom commented 2 years ago

On Ubuntu 22.04 to prevent a forced upgrade to 8.1 you need to install ondrej PPA, change the apt source file to impish and install php8.0 stuff you need. I still needed to install apcu via pecl though.

AndyScherzinger commented 2 years ago

@come-nc just as a ping, see https://github.com/nextcloud/server/issues/29287#issuecomment-1030301870

come-nc commented 2 years ago

As many of you know, Arch Linux packagers added some patches to NC23 to force it to run with PHP 8.1. However, there's a problem with UTF-8 characters in contact names and file names.

I'm guessing it's because of this change from PHP 8.0 to PHP 8.1:

htmlspecialchars(), htmlentities(), htmlspecialchars_decode(), html_entity_decode(), and get_html_translation_table() now use ENT_QUOTES | ENT_SUBSTITUTE rather than ENT_COMPAT by default. This means that ' is escaped to ' while previously nothing was done. Additionally, malformed UTF-8 will be replaced by a Unicode substitution character, instead of resulting in an empty string.

For example, if you try to create txt file named 'šđčćž', you will first get an error message, but the file will be created. However, you won't be able to delete it. When you choose to delete it, it will behave as it was deleted, but when you refresh the page it will be there.

So, this happens with NC23+PHP8.1, but not with NC23+PHP8.0.

I'm writing just to draw attention to this problem so that developers can make test case (if there isn't one already).

Is there any chance you could test this on master to see if it has the same problem? 23 does not support 8.1 and I’m not sure how much patching the ArchLinux packagers did. Could you open a dedicated ticket for this problem with reproduction instructions and link it here?

AndyScherzinger commented 2 years ago

@ambraspace see https://github.com/nextcloud/server/issues/29287#issuecomment-1039969572 - could you raise a dedicated issue for this, please. Highly appreciate your efforts ❤️

ambraspace commented 2 years ago

@C0rn3j @AndyScherzinger Sure. Please give me a day or two...

ambraspace commented 2 years ago

@come-nc @AndyScherzinger Yes, there's definitely a problem with UTF-8 with master branch and PHP 8.1. I will open separate issue.

ambraspace commented 2 years ago

@come-nc @AndyScherzinger here's the link: https://github.com/nextcloud/server/issues/31212 If needed, I can upload VM image for testing. Regards!

slapcat commented 2 years ago

A temporary workaround that doesn't involve downgrading the PHP version system-wide would be to specify the older version in the cronjob:

*/5 * * * * /usr/bin/php8.0 -f /var/www/html/nextcloud/cron.php

gelo2002 commented 2 years ago

A temporary workaround that doesn't involve downgrading the PHP version system-wide would be to specify the older version in the cronjob:

*/5 * * * * /usr/bin/php8.0 -f /var/www/html/nextcloud/cron.php

Be careful here! Even if cron jobs will work, as @bcutter mentioned, rest of the NC is still not fully functional. Eg. bug with non-UTF-8 characters...

markc commented 2 years ago

I just upgraded to Ubuntu 22.04 bumped into this issue with Nextcloud. All other PHP apps I use (Wordpress and Laravel) work fine with PHP 8.1. I'm not downgrading anything, so my not-preferred solution is to stop using Nextcloud.

kugel- commented 2 years ago

What's the deal with everyone?? You can co-install multiple versions of PHP on any Debian based system. And update-alternatives helps to manage them, perhaps by avoiding that 8.1+ is used automatically.

Nobody has to stop using nextcloud. 8.0 is easily available without downgrade.

markc commented 2 years ago

I'm not prepared to install the Sury PHP packages as that then brings in alternate dependencies (openssl etc) and I risk undoing an otherwise perfectly working system for WordPress and Laravel 9 development. I could spend the time to move my Nextcloud install to another server that has not been upgrade to 22.04, but I've been through this upgrade mismatch twice before over the last 5 years, and I'm not prepared to invest any more time in this BS. My path of the least resistance is to simply stop relying on Nextcloud.

Phillinger commented 2 years ago

So basically you are unwilling to check the dependencies of your software before updating and unwilling to make basic adjustments after your initial error. And now it's the "BS" of Nextcloud, that forced you into that situation to make this decision? I really understand your disappointment, but come on!

Scaenicus commented 2 years ago

any Debian based system

Yes.

There is no working PHP 8.0 set (including all necessary modules) available for SuSE, only 7.4 or 8.1. Currently I'm stuck with 7.4 and thus can't update any other application which would require 8.0+ after the upgrade. Which is okay for me, personally, but still valid for an open issue with Nextcloud.

Could we please keep this issue focused on waiting for 8.1. and not for shouting at each other. Thank you team!

gelo2002 commented 2 years ago

You can also do a workaround by using 2 (or more) different PHP version by setting virtual hosts (I use Apache2). I did it by hand, without any guides, but first result from google search looks exactly what's needed (though a bit older PHP and Debian versions...): Apache + Debian

darix commented 2 years ago

any Debian based system

Yes.

There is no working PHP 8.0 set (including all necessary modules) available for SuSE, only 7.4 or 8.1. Currently I'm stuck with 7.4 and thus can't update any other application which would require 8.0+ after the upgrade. Which is okay for me, personally, but still valid for an open issue with Nextcloud.

Could we please keep this issue focused on waiting for 8.1. and not for shouting at each other. Thank you team!

you could find php 8.0 packages in: https://build.opensuse.org/package/show/devel:languages:php:php80/php8

Scaenicus commented 2 years ago

Thank you @darix! I attempted that, however "including all necessary modules" was the problem. There were a couple without 8.0 support, even in community repositories. Unfortunately I haven't written down which failed, but APCu and memcache were two which had issues which were solvable. I believe the final straw was that I would have had to downgrade gcc. Anyhow, after trying to piece together a working PHP 8.0 for two hours I, reset to 7.4 and added checking this issue as a repeated task to my todo list.

(For anyone else: Please try above repository, because it might be an issue with my instance which is basically 14 years old and sometimes behaves badly it prodded too long... probably puberty)

jclsn commented 2 years ago

Nooo, I just upgraded my Debian to Bookworm. Skimmed the posts there and there seem to be workarounds for Ubuntu. I couldn't successfully install a repository with PHP8.0. Any suggestions?

ambraspace commented 2 years ago

Nooo, I just upgraded my Debian to Bookworm. Skimmed the posts there and there seem to be workarounds for Ubuntu. I couldn't successfully install a repository with PHP8.0. Any suggestions?

I switched to docker installation. I will probably keep it like that even after this gets fixed.

jclsn commented 2 years ago

@ambraspace Will give it a shot tomorrow

kugel- commented 2 years ago

@jclsn install php-8.0 (that exact version) via https://deb.sury.org/

ambraspace commented 2 years ago

@jclsn If it helps here are docker-compose.yml and relevant part of /etc/httpd/conf/extra/httpd-vhosts-le-ssl.conf:

docker-compose.yml:

version: "3.7"

networks:
  default:
    ipam:
      driver: default
      config:
        - subnet: 172.20.0.0/24

services:
  nextcloud:
    networks:
      - default
    volumes:
      - "/var/lib/nextcloud/data:/var/www/html/data"
      - "/var/lib/nextcloud/config:/var/www/html/config"
      - "/var/lib/nextcloud/apps:/var/www/html/custom_apps"
    image: nextcloud
    restart: unless-stopped
    ports:
      - 8080:80

httpd-vhosts-le-ssl.conf:

<VirtualHost *:443>
    ServerName your.server.name

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/<domain>/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/<domain>/privkey.pem

    <IfModule mod_headers.c>
        Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
    </IfModule>

    RewriteEngine on
    RewriteRule ^/\.well-known/carddav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]
    RewriteRule ^/\.well-known/caldav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]
    RewriteRule "^$" "/" [R,L]

    ProxyRequests off

    <Location "/">
      RequestHeader set X-Forwarded-Proto 'https'

      ProxyPreserveHost On
      ProxyPass http://127.0.0.1:8080/
      ProxyPassReverse http://127.0.0.1:8080/
    </Location>
</VirtualHost>

Just modify it so that files and directories point to your installation. I hope it helps.

elyograg commented 2 years ago

I upgraded from Ubuntu Server 20 to 22 and now I am discovering that a number of my PHP webapps are not compatible with php 8.1. This upgrade takes PHP from 7.4 to 8.1.

markc commented 2 years ago

Your only option is to install the Sury deb packages and downgrade to php 8.0. The Nextcloud folks have had 6 months to get this right and still no PHP 8.1 support for one of their largest OS system targets. My personal solution was to stop using Nextcloud.

mfb commented 2 years ago

on the other hand at least one major opcache bug will hopefully be fixed in PHP 8.1.6 so perhaps Nextcloud won't be too far behind the curve as far as PHP 8.1 being production ready..

come-nc commented 2 years ago

Nooo, I just upgraded my Debian to Bookworm. Skimmed the posts there and there seem to be workarounds for Ubuntu. I couldn't successfully install a repository with PHP8.0. Any suggestions?

Install Nextcloud 24 last RC and help us make sure that it fully support PHP 8.1?

elyograg commented 2 years ago

I copied the directory and the database to another server with php 7.4, and used the updater/updater.phar to upgrade in steps to version 23. Then I copied the updated database back to my ubuntu 22 server, and tried to do "occ upgrade" after copying my config and data directory from the old version directory to version 24 rc1 that I cloned from git. It seems to think I'm upgrading more than one major version, but the database is on version 23. I must be missing something important.

elyograg@smeagol:/var/www/cloud.elyograg.org$ sudo -u www-data php occ upgrade
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Setting log level to debug
Exception: Updates between multiple major versions and downgrades are unsupported.
Update failed
Maintenance mode is kept active
Resetting log level
elyograg commented 2 years ago

I cannot find any instructions on how to change the release channel. Lots of info about the dfifferent channels, but ZERO information on how to actually select a different channel. Keep in mind that I cannot access the administration section of the app ... because it will not run on PHP 8.1. If I try to browse to the app with version 24 rc1 (pointing at a version 23 database), I get a 504 error, with the following text:

The files of the app activity (activity), circles (circles), files_pdfviewer (files_pdfviewer), files_rightclick (files_rightclick), files_videoplayer (files_videoplayer), firstrunwizard (firstrunwizard), logreader (logreader), nextcloud_announcements (nextcloud_announcements), notifications (notifications), password_policy (password_policy), photos (photos), privacy (privacy), recommendations (recommendations), serverinfo (serverinfo), support (support), survey_client (survey_client), text (text), viewer (viewer) were not replaced correctly. Make sure it is a version compatible with the server.

My next step, which I didn't want to do because it's a lot of work, is to set up a virtualhost on the older system with php 7.4 and repoint the name there, and try to upgrade that to version 24rc1.

elyograg commented 2 years ago

I went ahead and did the full move of the application to the other server still running php7.4 ... and when I change the channel to beta, this is what I see at the top of the page:

[Nextcloud Hub II](https://nextcloud.com/) (23.0.4)

A new version is available: Nextcloud 22.2.7

EDIT: But if I click "open updater then it shows 24RC1, so this might be OK.

ghost commented 2 years ago

I cannot find any instructions on how to change the release channel. Lots of info about the dfifferent channels, but ZERO information on how to actually select a different channel. Keep in mind that I cannot access the administration section of the app ... because it will not run on PHP 8.1. If I try to browse to the app with version 24 rc1 (pointing at a version 23 database), I get a 504 error, with the following text:


The files of the app activity (activity), circles (circles), files_pdfviewer (files_pdfviewer), files_rightclick (files_rightclick), files_videoplayer (files_videoplayer), firstrunwizard (firstrunwizard), logreader (logreader), nextcloud_announcements (nextcloud_announcements), notifications (notifications), password_policy (password_policy), photos (photos), privacy (privacy), recommendations (recommendations), serverinfo (serverinfo), support (support), survey_client (survey_client), text (text), viewer (viewer) were not replaced correctly. Make sure it is a version compatible with the server.

My next step, which I didn't want to do because it's a lot of work, is to set up a virtualhost on the older system with php 7.4 and repoint the name there, and try to upgrade that to version 24rc1.

Just install Nextcloud 24 last RC and help us make sure that it fully support PHP 8.1 by following the undocumented procedure as said by @come-nc that will result in the breaking of your setup you lazy ass? 🤓🤓🤓🤓🤓

You devs are living on another planet. 🙄

elyograg commented 2 years ago

You devs are living on another planet.

In general, I am not a developer. I flirt with programming languages, and I think I'm actually sorta good at it, but in my career I have mostly been a system and/or network administrator.

I did finally get it all working, by completely moving the subdomain to a server still running php 7.4, upgrading it to NC 24 on that system, and then moving it all back to the primary server running Ubuntu 22. Somewhat painful, but it worked.

ghost commented 2 years ago

In general, I am not a developer. I flirt with programming languages, and I think I'm actually sorta good at it, but in my career I have mostly been a system and/or network administrator.

I did finally get it all working, by completely moving the subdomain to a server still running php 7.4, upgrading it to NC 24 on that system, and then moving it all back to the primary server running Ubuntu 22. Somewhat painful, but it worked.

I'm glad you got it working! It may haven't been clear but I had something against @come-nc answer, not yours. 😊

Congruentie commented 2 years ago

I just did a clean install of the latest production Ubuntu 22.04 LTS, Apache2, MySQL, PHP8.1.4 and all the mods I had to install for NextCloud as indicated by the web installer. That didn´t work, for otherwise I would not have found this forum ;). I am glad I did though. So next I installed the latest RC NextCloud 23.0.4 March 21 2022, to find the same result. I am pretty new to Ubuntu, but a fast learner. GitHub is completely new to me, so still figuring out where to find Version 24 ;), cause I couldn´t find it on the website. Willing to spend time figuring things out though.

come-nc commented 2 years ago

You should be able to switch release channel in the configuration page, or through the config file. Documentation about this is here: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#nextcloud-verifications More details about release channels: https://nextcloud.com/release-channels/

I did finally get it all working, by completely moving the subdomain to a server still running php 7.4, upgrading it to NC 24 on that system, and then moving it all back to the primary server running Ubuntu 22. Somewhat painful, but it worked.

Glad to see you found a way out of the locked down situation.