PHP 8+ Compatibility
We're currently running PHP 7.4 in our PHPCS set up and on the GC server, but some of us are using PHP 8+ in our development environments. (For example, #16948.)
This will be a catch-all ticket to address deprecated notices, fatal errors and the like.
Also, just to note that PHP 7.4 reached end-of-life back in November 2022. Upgrading to PHP 8.2 is probably good to think about when we decide to move hosts. PHP 8.2 is supported until December 2025, while PHP 8.0 will reach end-of-life in November 2023.
Updated by Raymond Hoh 4 months ago
I've added a commit to address the implicit conversion from float to int notice for the
cac_get_default_avatar() function here - https://github.com/cuny-academic-commons/cac/commit/0ffc3b8ae2166981eb5564bbbad780df241768ef .
invite-anyone also needed some changes to fix some deprecated notices, but I wasn't aware that the upstream versions already fixed them. I've backported those changes in the following commits - https://github.com/cuny-academic-commons/cac/commit/cb10f022b627315f2d0c01fb8d3980a629f9c005 , https://github.com/cuny-academic-commons/cac/commit/d481ae990c8a53ebe14fd0ade0afb6013781fed2 . Boone, are there any major changes between the upstream versions and our CAC version?
Updated by Boone Gorges 4 months ago
Boone, are there any major changes between the upstream versions and our CAC version?
No, I don't think so. I'll likely be performing updates to both plugins as part of the upcoming Commons In A Box release (~mid August), after which point the new versions will be on wordpress.org and will trickle down to the Commons. In the meantime, I don't see any harm in backporting some or all of the fixes to CAC.
Updated by Jeremy Felt 2 months ago
I think related to PHP 8 compat. :)
I have a branch open from master (
test/improve-php8-scan) that uses
dev-develop on the PHPCompatibility library. The PHPCompatibility library itself hasn't had a version release since 2019, and there are quite a few improvements pending. I landed on this config for quite a few other projects after seeing Juliette's guidance. The tests still pass as expected, so there is no real change other than (hopefully) increased reliability.
Updated by Jeremy Felt 3 days ago
I'm seeing a PHP warning (previously a notice) via CAC Courses when on PHP 8.2 in this line: https://github.com/cuny-academic-commons/cac-courses/blob/1f4bbb093e2b89760d9b1ba436ebd119e070ecb2/src/API.php#L44
I've adjusted this locally to be
$user = new \WP_User( $user['id'] ); return $user->user_login;
But I'm not sure what that may be impacting other than removing the warning for me. :)
Updated by Boone Gorges 3 days ago
I'm not sure the root of the issue, but I don't see any harm in the change https://github.com/cuny-academic-commons/cac-courses/commit/4ff624fa1288a969aa12623aba72ceb157f21679