Skip to content

Support PHP8.1 #29287

Description

@ChristophWurst

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

// Show warning if > PHP 8.0 is used as Nextcloud is not compatible with > PHP 8.0 for now
if (PHP_VERSION_ID >= 80100) {
http_response_code(500);
echo 'This version of Nextcloud is not compatible with > PHP 8.0.<br/>';
echo 'You are currently running ' . PHP_VERSION . '.';
exit(1);
}
.

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

Activity

  1. skjnldsv commented on Oct 18, 2021

    @skjnldsv
    Member

    cc @come-nc since you asked :)

  2. ChristophWurst commented on Oct 18, 2021

    @ChristophWurst
    MemberAuthor

    I checked the 3rdparty repo and no dep is actively blocking php8.1 right now (overrode the version number to test this)

  3. come-nc commented on Oct 18, 2021

    @come-nc
    Contributor

    Hello.

    I know at least that the use of LDAP resources will be a problem since there are calls to is_resource on ldap_* results in nextcloud code, and those are turned into objects instead in PHP 8.1.

    I’d be happy to start a PR to work on that if you want, and at least make sure the unittest suite for user_ldap works on 8.1. I can try to work on the rest of the test suite but I know less about it.

    It seems PHPCompatibility is not uptodate for 8.1 yet but at least they provide a nice list of things to look for: PHPCompatibility/PHPCompatibility#1299

  4. come-nc commented on Oct 18, 2021

    @come-nc
    Contributor

    There is this error for PHP 8.0 already:

    FILE: /home/mcmic/dev/nextcloud/server/lib/private/L10N/Factory.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------------
     595 | ERROR | Function create_function() is deprecated since PHP 7.2 and removed since PHP 8.0; Use an anonymous function instead
     600 | ERROR | Function create_function() is deprecated since PHP 7.2 and removed since PHP 8.0; Use an anonymous function instead
    -----------------------------------------------------------------------------------------------------------------------------------
    

    Not sure if this is known already, so noting it here before I forget.

  5. AndyScherzinger commented on Oct 18, 2021

    @AndyScherzinger
    Member

    thanks for the ping @ChristophWurst given the amount of time and people I'd not rush this for 23.0.0 also given the fact that apps might just break because they have php8.1 issues and that covers ours as well as community apps. So this seems to be to short notice for app devs and likely is also to risky for us and the v23 timeline given that we already reach beta status.

  6. come-nc commented on Oct 19, 2021

    @come-nc
    Contributor

    Needed for 8.1 support:

    • Bump symfony to 4.4.31 (only found 4.4.30 in composer, seems to be enough for now)
    • Fix pimple (or wait for a fix)
    • Bump doctrine/dbal to 3.1.2 or newer
    • Adapt code to support guzzlehttp/psr7 2.x (pulled by the changes above: https://github.com/guzzle/psr7#upgrading-from-function-api)
    • Bump guzzle to 7.4.0
  7. come-nc commented on Oct 21, 2021

    @come-nc
    Contributor

    Does anyone know the reason for d690f90 ?

  8. ChristophWurst commented on Oct 21, 2021

    @ChristophWurst
    MemberAuthor

    Does anyone know the reason for d690f90 ?

    #23780 (comment)

    I suggest we revert ans see what happens :)

  9. come-nc commented on Oct 21, 2021

    @come-nc
    Contributor

    There is a PHP error triggered by the call at https://github.com/nextcloud/server/blob/master/lib/private/Files/Cache/Propagator.php#L89 , because the second parameter is not given and it defaults to NULL at https://github.com/nextcloud/server/blob/master/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php#L421
    And it ends up in a call to PDO::quote on doctrine side, which triggers a warning as the type is supposed to be an int.
    The default value for $type in PDO::quote is PDO::PARAM_STR so I will switch to that if there are no objections.
    (writing all this here before forgetting why I made the change ^^)
    Actually we have IQueryBuilder::PARAM_STR which is an alias and I will use that to match the comment of the function

  10. come-nc commented on Oct 21, 2021

    @come-nc
    Contributor

    libxml_disable_entity_loader is deprecated but I do not understand what it does and why we call it. Leaving it in for now.

  11. nickvergessen commented on Oct 21, 2021

    @nickvergessen
    Member

    @LukasReschke will give you a lesson about it

  12. come-nc commented on Oct 21, 2021

    @come-nc
    Contributor

    The tests for Archive run into this problem: https://stackoverflow.com/questions/64698935/using-ziparchive-with-php-8-and-temporary-files
    I tried fixing it by this change:

    diff --git a/tests/lib/Archive/ZIPTest.php b/tests/lib/Archive/ZIPTest.php
    index 17a639c9f5..b6eb947f53 100644
    --- a/tests/lib/Archive/ZIPTest.php
    +++ b/tests/lib/Archive/ZIPTest.php
    @@ -17,6 +17,8 @@ class ZIPTest extends TestBase {
            }
     
            protected function getNew() {
    -               return new ZIP(\OC::$server->getTempManager()->getTemporaryFile('.zip'));
    +               $tmpfile = \OC::$server->getTempManager()->getTemporaryFile('.zip');
    +               \unlink($tmpfile);
    +               return new ZIP($tmpfile);
            }
     }
    

    But I get a misterious warning at the end of the tests:

    PHP Warning:  PHPUnit\TextUI\Command::main(): Cannot destroy the zip context: Can't remove file: No such file or directory in /home/mcmic/.config/composer/vendor/phpunit/phpunit/src/TextUI/Command.php on line 96
    

    No idea if the actual code is concerned.

  13. come-nc commented on Oct 21, 2021

    @come-nc
    Contributor

    In several cases there are PHP warnings in the tests because the Mock returns null instead of string or int.
    When the return type is only present in the phpdoc and is not there as a return type this happens I think.

  14. 117 remaining items

  15. blacklight commented on May 26, 2022

    @blacklight

    @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.

  16. AndyScherzinger commented on May 26, 2022

    @AndyScherzinger
    Member

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

  17. VVD commented on Jun 27, 2022

    @VVD

    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 ?? '');
    
  18. AndyScherzinger commented on Jun 27, 2022

    @AndyScherzinger
    Member

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

  19. VVD commented on Jun 27, 2022

    @VVD

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

  20. ChristophWurst commented on Jun 27, 2022

    @ChristophWurst
    MemberAuthor
  21. VVD commented on Jun 27, 2022

    @VVD

    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: swiftmailer/swiftmailer@ee8a1d9
    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?

  22. VVD commented on Jul 19, 2022

    @VVD

    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',
    
  23. AndyScherzinger commented on Jul 19, 2022

    @AndyScherzinger
    Member

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

  24. VVD commented on Jul 20, 2022

    @VVD
  25. added a commit that references this issue on Aug 22, 2022
  26. creopard commented on Nov 9, 2022

    @creopard

    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 swiftmailer/swiftmailer@ee8a1d9 that were not yet integrated into https://github.com/nextcloud/3rdparty/tree/master/swiftmailer/swiftmailer ?

  27. ChristophWurst commented on Nov 9, 2022

    @ChristophWurst
    MemberAuthor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions