nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
26.97k 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

come-nc commented 2 years ago

Note that it is also possible to download RC version from https://nextcloud.com/install in the «Get involved» section bottom right.

jancborchardt commented 2 years ago

Hi @mthld, please keep a friendly and constructive tone. Nextcloud is an open source project & community, so everyone is participating – it's not just a few people developing for an audience. Thank you! :)

J4gQBqqR commented 2 years ago

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 went through a more painful experience by upgrading my Ubuntu 20 to Ubuntu 22. Nextcloud suddenly disconnects. Fearing that I am hacked and losing data, unplugged my Ethernet cable...

Suspect that the issue is due to php upgraded to 8.1 in Ubuntu, first tried php8.0 as it is marked as recommended in the documentation. It does not work. So many required modules cannot be found for php8.0 ... Does anyone know why? If 8.0 has so little modules available, why is it recommended in the official documentation?

Then uninstall the whole php8 and went back to 7.4. Note that I did all these via USB drive without ethernet pluggin in. Very painful...

@jancborchardt I understand your point about not developing for a single audience. But please note that a potentially significant percentage of the audiences are running Ubuntu and will upgrade to Ubuntu 22.

Potentially a large number of audiences will not know Nextcloud will fail until they landed in Ubuntu 22 and starting to research for the point of failure and landed here.

What is this threading telling us? Issue opened since October, 2021. Developers are working hard to make it work for the past half a year. And it is decided to be put into NC24.

So basically you are unwilling to check the dependencies of your software before updating and unwilling to make basic adjustments after your initial error.

What's the deal with everyone??

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

I guess this is telling me that it is time for me to embrace docker instead of maintaining the service myself. "Willing to check dependencies before upgrading" is not something that I want to do for all my services and for each upgrade.

Please, please, discuss internally within Nextcloud developers about the priority of Nextcloud support for php8.1, not in long pending future release of 24, but in the current release of 23. Hope that the community's feedback can be heard.

ghost commented 2 years ago

Nextcloud server 24.0.0 stable is released. :tada: No problems with php8.1.

Did i miss anything or can this issue be closed now?

pooh22 commented 2 years ago

Hi Jens, though I'm not the one who posted this bugreport, I think this issue is/has become more about quality and support than whether a version of nextcloud supports php8.1. The original poster mentioned a month in advance about the upcoming php 8.1 release and how this would affect all nextcloud admins running NC22. Not providing a timely fix for all supported NC versions for php8.1 has been a dissapointment for all posters in this issue, I'm sure. Since I'm not a developer, I don't know exactly why this was such a big problem, but as sysadmin, I want to be sure all software I run is safe to run on the latest stable OS releases.

I'm very grateful for all people working on NC to provide it and all the features and plugins that I love to use. And I know it's open source and as such can be a bit of a rough ride sometimes. Still the way this particular issue was handled makes me want to look elsewhere for the same functionality (haven't found it though).

For my part, I would close this when the php 8.1 support is backported to at least NC23 and not before that. Also I would love some re-assurance that this kind of FU will not be happening again anytime soon.

jclsn commented 2 years ago

Yeah, next problem: Nextcloud can't update from 22 to 24. Since 23 doesn't work with PHP8.1, I have to start from scratch...

seuffert commented 2 years ago

Yeah, next problem: Nextcloud can't update from 22 to 24. Since 23 doesn't work with PHP8.1, I have to start from scratch...

I had the same problem. Download nc24 and update manually on command line.

jclsn commented 2 years ago

@seuffert : How? That is what I tried.

$ 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

I already tried the docker version as well, which doesn't work. This is really getting painful.

unilock commented 2 years ago

@jclsn @seuffert Upgrading manually via the command line still requires incremental upgrades between major versions IIRC. The only(?) solution would be to set up a (virtual?) system with PHP 7.4 or 8.0, backup and move your Nextcloud configuration to it, use that setup to migrate to 22 -> 23 -> 24, then move your Nextcloud config back to the original system.

jclsn commented 2 years ago

@unilock Not on a Saturday.

I will use the AIO docker version now. It seems to work this time.

elyograg commented 2 years ago

The only(?) solution would be to set up a (virtual?) system with PHP 7.4 or 8.0, backup and move your Nextcloud configuration to it, use that setup to migrate to 22 -> 23 -> 24, then move your Nextcloud config back to the original system.

This is what I did. I changed where my front end haproxy was directing that domain, copied the database and installation files to another machine still running PHP 7.4, upgraded it to 24 there, made sure it was working, and then moved it back to the server I had upgraded to Ubuntu 22.

Upgrading the OS broke most of my PHP-based web applications. Seems very few projects were prepared for changes in PHP 8. I've been commenting on bug reports all over the place trying to get things fixed.

One website, written for uwsgi, I couldn't make it run at all. I found some PHP replacements, but I couldn't get any of those working with PHP 8.1, so I picked one of them, installed it on that older system, and now it works.

The system still running the older PHP version is a NanoPi. https://raspi2.elyograg.org/ I have upgraded all my servers except that one to Ubuntu 22. Who knows how long before the ubuntu-derived OS I'm running on the NanoPi will have an upgrade available. I may not upgrade it for quite a while, because it is a last refuge where I can run apps that I simply cannot make work with PHP 8.

C0rn3j commented 2 years ago

@ChristophWurst Did anything actually change to prevent this situation in the future, or will this exact same situation play out in the future with 8.2?

Is the Nextcloud team going to track PHP development/beta releases and make sure current major Nextcloud releases get support in patch versions?

Please note the huge amount of likes and the amount of participants in this thread.

AndyScherzinger commented 2 years ago

We are aware that there are many likes on this topic but I am afraid you will have to live with the risk that this might happen again in the future for certain scenarios, the ones we also faces with 8.1. There have been 3rd party libraries we use, i.e. sabre that haven't been compatible with 8.1 in the recent past. This basically makes it impossible then to support 8.1 right from the initial release.

I understand that anybody who can would love to simply always run everything at latest-and-greatest, I am the first in line here. However we do state in the requirements with which versions of the underlying system/platform we are compatible.

The question with the patch version is hard to answer, we did our best to get it compatible with 24.0.0 and if there is something still not right we would fix in a patch/minor release of 24 since that is the latest major release however we do not backport new version support to older Nextcloud version to keep changes within a major release rather small as in mostly fixes. This implies that new PHP version support is something I do not consider a bug and thus only targets the latest release.

So I keep my fingers crossed looking at 8.2 of PHP that we won't run into the same scenario and all the used libraries will support it right from the start but there is no guarantee.

I hope this sheds some light on the how and why things tunrned out the way they did.

jamiew0w commented 2 years ago

hi guys and girls. is there any plans to help people stuck on nc22 upgrade to nc24? (IE an easier upgrade path)

nanaya commented 2 years ago

I haven't tried this but if you can get older php binary somehow in the system (phpenv, etc), maybe try running /path/to/bin/php7.4 updater/updater.phar from cli to update to version 24? (or whatever the php version and path)

rdlab-upc commented 2 years ago

@jclsn @elyograg @jamiew0w @C0rn3j et al

Maybe this workaround will help for Ubuntu 22.04 and Nextcloud 22/23/24, at least our tests worked fine and clean. Ondrej (now) provides php 8.0 packages for Jammy 22.04 (https://launchpad.net/~ondrej/+archive/ubuntu/php)

HowTo add php8.0 under Ubuntu 22.04

  1. Add Ondrej repository sudo add-apt-repository ppa:ondrej/php

  2. Update sources

sudo apt update

  1. Install php8.0 with desired modules

apt-get install php8.0 php8.0-cli php8.0-fpm .....

  1. (OPTIONAL) make php8 default in your system (for cron/cli executions)

sudo update-alternatives --config php

P.S: Probably you need to change/restart the fastcgi_pass unix:/run/php/php-fpm.sock; in your apache/nginx configuration to point out to /var/run/php/php8.0-fpm.sock

P.S2: You can also delete all php-8.1 system packages if no more system dependencies exist, but IMHO is better having both versions available in the system.

@AndyScherzinger @pooh22 First of all a big thank you and real acknowledge to the NC team, great job!. It is plain to see the big effort you made this past months.

Said so, IMHO, this issue could be addressed more politely from the developer team. (some ;) Claims are nicely motivated and explained and replies like "So I keep my fingers crossed looking at 8.2 of PHP that we won't run into the same scenario and all the used libraries will support it right from the start but there is no guarantee." do not provide trustworthiness in this project.

I know and understand that this is a community initiative lead by NC staff, so the community (we would like to believe we belong to) must actively contribute and not only complain about "my own needs". This is why we share this "howto" in order to help address this problem.

Sorry for the looong post ;)

Thank you!

notandxor commented 2 years ago

Got bitten by this by a fedora 36 upgrade. Downgardig to php 8.0, this saved my day: https://rpms.remirepo.net/wizard/

xxblx commented 2 years ago

Thanks @notandxor! It's also possible to install php 8.0 as a separate version and use it for upgrading only, i.e., without downgrading php system-wide.

Workaround for Fedora 36 - enabling remi and installing php 8.0 in parallel with php 8.1

dnf install https://rpms.remirepo.net/fedora/remi-release-36.rpm
dnf config-manager --set-enabled remi
# check package names and adapt to match your setup (postgres / mysql, etc.)
dnf install php80 php80-php-pgsql php80-php-pecl-apcu php80-php-intl php80-php-intl php80-php-gd php80-php-xml php80-php-pdo php80-php-process php80-php-pecl-zip php80-php-mbstring

Once php 8.0 is installed, do manual upgrade with php80. I applied --define as I didn't configure php80 because I was not going to keep it after the upgrade.

php80 --define apc.enable_cli=1 occ upgrade

I upgraded 22.2.5 => 22.2.8 => 23.0.5 with php80 and after that upgraded nc to 24.0.1 using default php from the fedora repository. So far 24.0.1 has been working fine with php 8.1.

blacklight commented 2 years ago

I've kept my php* packages on hold on Arch Linux for way too long (while waiting for NC 24 to be rolled out, hopefully with PHP 8.1 support). And this is starting to affect other occ commands that can no longer find the versions of the libraries that they expect:

PHP Warning:  PHP Startup: Unable to load dynamic library 'intl' (tried: /usr/lib/php/modules/intl (/usr/lib/php/modules/intl: cannot open shared object file: No such file or directory), /usr/lib/php/modules/intl.so (libicudata.so.70: cannot open shared object file: No such file or directory)) in Unknown on line 0

Note that Arch Linux doesn't support partial upgrades, so this was expected to happen at some point. I just hoped that I didn't have to hold on the PHP system packages for ~7 months, and now the system itself is starting to fall apart.

How am I supposed to tackle this when the upgrade to NC 24 comes to my instance, since occ commands are most likely to fail because some of the dependencies that they rely on have been upgraded?

As a lesson for next time, could you guys start testing NC against the upcoming version of PHP before the new version is rolled out to all the systems out there, instead of being caught by surprise every time, and rush to get a fix after the first issues have already been open?

nettybun commented 2 years ago

@BlackLight you should not have needed to hold back PHP versions, as Arch patched their Nextcloud 23 to support PHP 8.1 months ago beginning in January https://github.com/archlinux/svntogit-community/commit/c78893ca625b81a48d3201ac31dff70b2477133f

Also mentioned at the start of https://wiki.archlinux.org/title/Nextcloud

zynexiz commented 2 years ago

@BlackLight Had my PHP on hold to for a while, but upgraded to v24.0.0 a week or two ago, released the hold and upgraded everything. It all works very good again now, and think actually NC got a bit faster (feels snappier anyway). Just updated to 24.0.1 yesterday, still running good. I don't use NC package from repo thou because of my structure on my web server and stuff.

blacklight commented 2 years ago

@BlackLight you should not have needed to hold back PHP versions, as Arch patched their Nextcloud 23 to support PHP 8.1 months ago beginning in January archlinux/svntogit-community@c78893c

I don't have the NC package installed via pacman. I installed it directly in my Apache directory because of quirks/customizations with my server. And the upgrade to NC 24 hasn't yet come in my mailbox. And when it comes, it's likely to break because of the mismatch between expected/available dependencies of PHP. What shall I do in this case? A few options:

zynexiz commented 2 years ago

@BlackLight You should be able to upgrade thru the UI (or shell), v24.0.0 has been there for a while now (and also v24.0.1, at least for the stable release). I did my upgrade a couple of weeks ago. Can confirm that it works with latest PHP in arch repo. I upgraded NC first, then released the packages and did pacman -Syyu on everything.

nariox commented 2 years ago

On Arch, php7 is still part of the official repos. I keep both of them installed just in case. Not the most minimalistic, but they tend to upgrade php really quickly, so it's a good idea to have it installed just in case.

On Wed, May 25, 2022 at 5:56 AM Michael @.***> wrote:

@BlackLight https://github.com/BlackLight You should be able to upgrade true the UI (or shell), v24.0.0 has been there for a while now (and also v24.0.1). I did my upgrade a couple of weeks ago. Can confirm that it works with latest PHP in arch repo. I upgraded NC first, then released the packages and did pacman -Syyu on everything.

— Reply to this email directly, view it on GitHub https://github.com/nextcloud/server/issues/29287#issuecomment-1137039530, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHWYSCB5AZJ5YNL35J7JH3VLX2N7ANCNFSM5GF5B4XQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

AndyScherzinger commented 2 years ago

@BlackLight if the updater doesn't offer v24 yet, just switch to the beta channel, than it will pop-up, upgrade to 24, then switch back to stable. This way you can work around the staged roll-out.

@rdlab-upc regarding the trustworthiness I feel the need to reply to that and clearify this a bit more. Also thank you for your detailed comment and guidance for others. We do our best to prevent such situations, see i.e. https://github.com/nextcloud/groupware/issues/40 where we try to catch such things early on. Like I stated Nextcloud like many software systems nowadays depend on 3rd party libraries to implement their functionality i.e. horde and sabreDAV. So when the 3rd party libraries aren't yet compatible then also Nextcloud is stuck with the defined PHP versions. Because of that we do document the versions Nextcloud is compatible with. Sometimes you are lucky and can work around incompatibilities in libraries, sometimes you can't. So there is nothing you as a dev can do about this. That is why I basically stated that Nextcloud can't guarantee compatibility with new php versions on day one but will always try do achieve that. So I rather find such a statement trustworthy compared to stating "yeah, we will" even though technically speaking we can't ensure this except also taking over all the used libs.

blacklight commented 2 years ago

@AndyScherzinger thanks for the instructions. I have eventually managed to upgrade manually (downloaded the latest zip to the Apache dir and ran occ upgrade). Then after upgrading to NC 24 I upgraded PHP to 8.1 and everything went fine. I was afraid that some of the missing system dependencies would break the occ upgrade process, but luckily the only PHP module that was broken (because it relied on the libcuuc* libraries that were upgraded) was intl, which apparently is not mandatory for the upgrade to run.

AndyScherzinger commented 2 years ago

My pleasure @BlackLight and happy to hear you arrived on 24 safely 👍

VVD commented 2 years ago

Several errors:

strtolower(): Passing null to parameter #1 ($string) of type string is deprecated at /nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php#144

3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php#144:

-$encryption = strtolower($encryption);
+$encryption = strtolower($encryption ?? '');
str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated at /nextcloud/apps/mail/vendor/bytestream/horde-mime/lib/Horde/Mime/Headers/Element.php#145

apps/mail/vendor/bytestream/horde-mime/lib/Horde/Mime/Headers/Element.php#145:

-return str_replace("\0", '', $data);
+return str_replace("\0", '', $data ?? '');
AndyScherzinger commented 2 years ago

@VVD please raise this at https://github.com/nextcloud/mail/issues including the version infos server/mail-app

VVD commented 2 years ago

Can't find files EsmtpTransport.php and Element.php in sources of the https://github.com/nextcloud/mail/. Both are something else.

ChristophWurst commented 2 years ago

3rdparty/swiftmailer

https://github.com/nextcloud/3rdparty / https://packagist.org/packages/swiftmailer/swiftmailer

bytestream/horde-mime

https://github.com/bytestream/Mime, addressed in https://github.com/bytestream/Mime/pull/3 and pulled via https://github.com/nextcloud/mail/pull/6647. Unreleased.

VVD commented 2 years ago

Thanks for information.

3rdparty/swiftmailer

https://github.com/nextcloud/3rdparty / https://packagist.org/packages/swiftmailer/swiftmailer

This package is abandoned and no longer maintained.
The author suggests using the [symfony/mailer](https://packagist.org/packages/symfony/mailer) package instead.

Found commit with PHP8.1 support: https://github.com/swiftmailer/swiftmailer/commit/ee8a1d9684ba571e4c0f9b857b1a81a9c419186b It have "my" patch too.

bytestream/horde-mime

https://github.com/bytestream/Mime, addressed in bytestream/Mime#3

Already fixed, but when we can see it in our installation? What are the plans?

VVD commented 2 years ago

During upgrade from 24.0.2 to 24.0.3 I got error:

<b>Deprecated</b>:  Return type of RecursiveDirectoryIteratorWithoutData::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in <b>/opt/nextcloud/updater/index.php</b> on line <b>40</b><br />
{"proceed":true}

Patch:

--- updater/index.php.orig
+++ updater/index.php
@@ -37,7 +37,7 @@
 }

 class RecursiveDirectoryIteratorWithoutData extends \RecursiveFilterIterator {
-       public function accept() {
+       public function accept(): bool {
                /** @var \DirectoryIterator $this */
                $excludes = [
                        '.rnd',
AndyScherzinger commented 2 years ago

@VVD can you please raise a new issue for this one, thanks, your effort is highly appreciated, cc @PVince81

VVD commented 2 years ago

@AndyScherzinger, https://github.com/nextcloud/server/issues/33295

creopard commented 1 year ago

Several errors:

strtolower(): Passing null to parameter #1 ($string) of type string is deprecated at /nextcloud/3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php#144

3rdparty/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php#144:

-$encryption = strtolower($encryption);
+$encryption = strtolower($encryption ?? '');

@ChristophWurst (cc @AndyScherzinger ) The above issue with swiftmailer found by @VVD is still open in Nextcloud 25.0.1 and pops up regularely in the NC error log when sending an email.

What about the existing fixes https://github.com/swiftmailer/swiftmailer/commit/ee8a1d9684ba571e4c0f9b857b1a81a9c419186b that were not yet integrated into https://github.com/nextcloud/3rdparty/tree/master/swiftmailer/swiftmailer ?

ChristophWurst commented 1 year ago

Could you open that as a separate ticket please @creopard? Then one of the server engineers can have a look.