Warning messages "ucwords() expects exactly 1 parameter" after Update to 3.11.0

Hello,

after updating our Matomo system to 3.11.0, I get these warning messages (many of them) in some of the admin panels – but not always, sometimes I reload the page and they disappear.

WARNING: /var/www/piwik/core/Http.php(868): Warning - ucwords() expects exactly 1 parameter, 2 given - Matomo 3.11.0

There is also a warning that Matomo will stop supporting our PHP version in the next major version but I don’t think that this is the reason for the other warning messages. Or maybe it is? We are currently preparing a PHP update on this system.

Any ideas?

Cheers

Thorsten

Hi,

You are right, this is a new bug:

A change introduced in the latest release uses a PHP feature that has only been added in 5.5.16.

I guess you are using a 5.5 version below. This is a bug as Matomo does support those versions, but personally I would really recommend you to not use a PHP version that came out 5 years ago and upgrade to a newer one. Unless someone is backporting all security fixes that came since to your specific version, it is probably really insecure.

And Matomo 4 will (when it comes out one day) require PHP 7.1 or newer anyway.

1 Like

Thanks for your answer.

Our admin is working on the PHP update… :slight_smile:

2 Likes

Unfortunately PHP 5.5.9 is all that’s available in the latest CentOS 7 official software repositories (and in some workplaces there’s not the flexibility to choose a different distribution of Linux). Critical fixes are supposed to be backported so that this old-sounding PHP version should still be secure on CentOS. However it makes it difficult when Matomo and other software is (understandably) moving to support only more recent versions of PHP.

Hi @warwick,

Matomo does still support PHP 5.5.9. This is just a bug that will be fixed in 3.12.

If you don’t want to wait, appy the following patch to core/Http.php:

diff --git a/core/Http.php b/core/Http.php
index ab75caa0da..b7b93e5e89 100644
--- a/core/Http.php
+++ b/core/Http.php
@@ -865,9 +865,12 @@ private static function parseHeaderLine(&$headers, $line)
          * With HTTP/2 Cloudflare is passing headers in lowercase (e.g. 'content-type' instead of 'Content-Type') 
          * which breaks any code which uses the header data. 
          */
-        $camelName = ucwords($name, '-');
-        if ($camelName !== $name) {
-            $headers[$camelName] = trim($value);
+        if (version_compare(PHP_VERSION, '5.5.16', '>=')) {
+            // Passing a second arg to ucwords is not supported by older versions of PHP
+            $camelName = ucwords($name, '-');
+            if ($camelName !== $name) {
+                $headers[$camelName] = trim($value);
+            }
         }
     }

Just keep in mind that once Matomo 4 will come out one day (development will start probably after 3.12 or 3.13) it will only support PHP 7.1+ as by then maintaining 6 PHP versions becomes too much.