Recurring update issue through 34.0.x updates under PHP 8.3 (undefined constants)

A quick “info” post in case this could be of use to others.

For basic context, my instance is hosted on a classic LAMB provider.

During my most recent update rounds (usually done via the web updater), I’ve had to resort not only to occ, but also tinker with “/lib/private/Http/Client/Client.php” for the update to succeed.

Via the Web updater, the update partially proceeds with green ticks up to the “DB update” line, then fails on the next step (red X followed by an empty line).

Resorting to occ upgrade, I was faced with the following errors:

Setting log level to debug
Updating database schema
Updated database
An unhandled exception has been thrown:
Error: Undefined constant "CURL_HTTP_VERSION_2TLS" in /domain.xxx/lib/private/Http/Client/Client.php:52
Stack trace:
#0 /domain.xxx/lib/private/Http/Client/Client.php(214): OC\Http\Client\Client->buildRequestOptions(Array)

and (upon resolution of the above)

Setting log level to debug
Updating database schema
Updated database
An unhandled exception has been thrown:
Error: Undefined constant "OC\Http\Client\CURL_VERSION_BROTLI" in /domain.xxx/lib/private/Http/Client/Client.php:91
Stack trace:
#0 /domain.xxx/lib/private/Http/Client/Client.php(214): OC\Http\Client\Client->buildRequestOptions(Array)

Upon research and tinkering, it appears this might be due to those constants possibly not available in PHP 8.3 (running 8.3.32 in my case), but versions 8.4 or 8.5 aren’t available yet on my hosting.

I’ve tried a variety of suggestions relating to “CURL_HTTP_VERSION_2TLS” and “CURL_VERSION_BROTLI” errors, but with no positive outcome, so here’s what I tried that worked in my case.

Edit the following:
$defaults['curl'][\CURLOPT_HTTP_VERSION] = \CURLOPT_HTTP_VERSION; (line 52 in my case)

to
$defaults['curl'][\CURLOPT_HTTP_VERSION] = 84;

and

if (((curl_version()['features'] ?? 0) & CURL_VERSION_BROTLI) === CURL_VERSION_BROTLI) { (line 91 for me)

to

if (((curl_version()['features'] ?? 0)) === 8388608) {

Those will also have to be left as is for the NC instance to work (therefore I ignore the integrity warning for that file).

After those edits, I was able to update/upgrade successfully. I find it quite strange however that NC code would resort to constants that only exist in PHP 8.4+, as the docs says PHP versions from 8.2 to 8.5 are OK. Maybe this is a PHP settings anomaly at my provider ? I considered filing a bug, but NC’s github says “No server is currently available to service your request” at the moment :wink:

Doing some additional search as part of this, the above might be a mix of PHP and Curl version “trouble”.

Here’s what led me to doubt constant definition availability for CURLOPT_HTTP_VERSION and PHP 8.3 CURLOPT_HTTP_VERSION Constant • PHP.Watch

For CURL_VERSION_BROTLI , the Curl version might be the main issue in my case, as my provider shows curl 7.29.0 but the "constant availability is in the same state CURL_VERSION_BROTLI Constant • PHP.Watch

I’ll have a word with my provider though, because that curl 7.29 seems to be 13+ years old curl - Release Table

Wich doc says that? This one (System requirements — Nextcloud 34 Administration Manual) say PHP 8.2 (deprecated):

But well you use 8.3 and i a am aware of that. Just want to take care anyone reading this will notice 8.2 is deprecated.

I was indeed referring to that source. My understanding is that the “deprecated” mention refers to PHP 8.2 being EOL (security support ending this year PHP | endoflife.date). If Nextcloud 34 did not support it, it simply would not appear in its requirements.

This is 100% because of an ancient libcurl installation in your hosting environment.

It I were to make a wild guess, they’re running RHEL 7, which was first released back in 2014.

This is also why, among other things, the Nextcloud server requirements are for RHEL >= 9:

Right on point, hosting provider mentioned a CentOS 7, soon to be migrated to AlmaLinux. Hopefully things will get better/less outdated then.