SOLVED: Nextcloud Logs "Trying to access array offset on value of type null" Repeatedly

Nextcloud version (eg, 12.0.2) : 18.0.0-1
Operating system and version (eg, Ubuntu 17.04) : Arch Linux 5.4.13-arch1-1
Apache or nginx version (eg, Apache 2.4.25) : nginx-mainline 1.17.7-1
PHP version (eg, 7.1) : 7.4.1
All Nextcloud apps are current versions as of today (1/21/20)

The issue you are facing:

After upgrading Nextcloud and PHP, and installing a couple of new Nextcloud apps, I am receiving repeated messages in the log file about “Trying to access array offset on value of type null.”

Nextcloud appears to be working without issue.
PHP is working without issue.
MySQL is working without issue.

Is this the first time you’ve seen this error? (Y/N) : Y

Steps to replicate it:

  1. Upgrade Nextcloud from 17.x to 18.0
  2. Upgrade PHP from 7.3 to 7.4.1
  3. Install/enable Nextcloud “Notes” and “Tasks” apps
  4. Reboot server

The output of your Nextcloud log in Admin > Logging :

These are just a few of the log entries. There are many like these, but they are all of this same theme.

{"reqId":"x","level":3,"time":"2020-01-20T22:29:36+00:00","remoteAddr":"1.1.1.1","user":"me","app":"PHP","method":"GET","url":"/apps/calendar/","message":"Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"18.0.0.10"}
{"reqId":"x","level":3,"time":"2020-01-20T22:29:36+00:00","remoteAddr":"1.1.1.1","user":"me","app":"PHP","method":"GET","url":"/apps/calendar/","message":"Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"18.0.0.10"}
{"reqId":"x","level":3,"time":"2020-01-20T22:29:36+00:00","remoteAddr":"1.1.1.1","user":"me","app":"PHP","method":"GET","url":"/apps/calendar/","message":"Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"18.0.0.10"}
{"reqId":"x","level":3,"time":"2020-01-20T22:29:36+00:00","remoteAddr":"1.1.1.1","user":"me","app":"PHP","method":"GET","url":"/apps/calendar/","message":"Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"18.0.0.10"}
{"reqId":"x","level":3,"time":"2020-01-20T22:29:36+00:00","remoteAddr":"1.1.1.1","user":"me","app":"PHP","method":"GET","url":"/apps/calendar/","message":"Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"18.0.0.10"}
{"reqId":"x","level":3,"time":"2020-01-20T22:29:36+00:00","remoteAddr":"1.1.1.1","user":"me","app":"PHP","method":"GET","url":"/apps/calendar/","message":"Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"18.0.0.10"}
{"reqId":"x","level":3,"time":"2020-01-20T22:29:36+00:00","remoteAddr":"1.1.1.1","user":"me","app":"PHP","method":"GET","url":"/apps/calendar/","message":"Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"18.0.0.10"}
{"reqId":"x","level":3,"time":"2020-01-20T22:29:36+00:00","remoteAddr":"1.1.1.1","user":"me","app":"PHP","method":"GET","url":"/apps/calendar/","message":"Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"18.0.0.10"}
{"reqId":"x","level":3,"time":"2020-01-20T22:29:36+00:00","remoteAddr":"1.1.1.1","user":"me","app":"PHP","method":"GET","url":"/apps/calendar/","message":"Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"18.0.0.10"}
{"reqId":"x","level":3,"time":"2020-01-20T22:29:36+00:00","remoteAddr":"1.1.1.1","user":"me","app":"PHP","method":"GET","url":"/apps/calendar/","message":"Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"18.0.0.10"}
{"reqId":"x","level":3,"time":"2020-01-20T22:29:36+00:00","remoteAddr":"1.1.1.1","user":"me","app":"PHP","method":"GET","url":"/apps/calendar/","message":"Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0","version":"18.0.0.10"}

Here’s my config.php file in /path/to/nextcloud:

<?php
$CONFIG = array (
  'instanceid' => 'xxxxxxxxxxx',
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxx',
  'trusted_domains' => 
  array (
    0 => 'my.domain.com',
  ),
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'dbindex' => 0,
    'password' => 'xxxxxx',
    'timeout' => 1.5,
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'datadirectory' => '/pathto/data',
  'dbtype' => 'mysql',
  'version' => '18.0.0.10',
  'overwrite.cli.url' => 'https://my.domain.com',
  'dbname' => 'xxxxx',
  'dbhost' => 'localhost',
  'dbport' => '3306',
  'dbtableprefix' => 'xxx_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'me',
  'dbpassword' => 'xxxxxxxxxxxxxxxxx',
  'installed' => true,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud-error.log',
  'loglevel' => 3,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'me',
  'mail_domain' => 'domain.com',
  'mail_smtpauthtype' => 'PLAIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'mail.domain.com',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'me@domain.com',
  'mail_smtppassword' => 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
  'maintenance' => false,
  'theme' => '',
);

The contents of my /nginx/system log in /var/log/nginx :

2020/01/20 15:29:38 [error] 1017#1017: *558 FastCGI sent in stderr: "PHP message: PHP Deprecated:  The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /usr/share/webapps/nextcloud/3rdparty/sabre/vobject/lib/Recur/RRuleIterator.php on line 357PHP message: PHP Deprecated:  The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /usr/share/webapps/nextcloud/3rdparty/sabre/vobject/lib/Recur/RRuleIterator.php on line 423" while reading response header from upstream, client: 1.1.1.1, server: my.server.com, request: "REPORT /remote.php/dav/calendars/me/mine/ HTTP/2.0", upstream: "fastcgi://unix:/run/php-fpm/php-fpm.sock:", host: "my.domain.com"

I am seeing the same repeated errormessages in my logs, after my install on Centos 7.
Does anyone have an idea how this error can be resolved?

Yep, and I see that this problem is scheduled for resolution with the Nextcloud 19 Milestone (planned 5/21/20 release date)

Meanwhile (to keep my logfile activity at a sane level), does anyone know how to modify the PHP file in question to stop this error (for me it’s /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php line 5230).

Here’s the function, and line #5230 reads $end = (int) $args[2][1]; below:

protected function libStrSlice($args)
{
    if (isset($args[2]) && $args[2][1] == 0) {
        return static::$nullString;
    }

    $string = $this->coerceString($args[0]);
    $stringContent = $this->compileStringContent($string);

    $start = (int) $args[1][1];

    if ($start > 0) {
        $start--;
    }

    $end    = (int) $args[2][1];
    $length = $end < 0 ? $end + 1 : ($end > 0 ? $end - $start : $end);

    $string[2] = $length
        ? [substr($stringContent, $start, $length)]
        : [substr($stringContent, $start)];

    return $string;
}

I searched for a patch on github, but I didn’t find anything or this file and version

1 Like

I’d definitely like to know that as well. But sorry, @buzz, I do not have the solution here.

I’m no PHP expert, but changing the first line of that function into

if (isset($args[2]) && isset($args[2][1]) && $args[2][1] == 0) {

adds a null check to the $args[2][1] and seems to stop the message from appearing at my instance without any other effects (but how can you be sure in a source with 5000+ lines).

I can’t find this file in the Nextcloud repo on Github. Can someone tell me what this it belongs to so that I can run tests and submit a patch?

EDIT: never mind, found it: https://github.com/scssphp/scssphp

2 Likes

@WhyYes, Thank you! This fixed it for me.

I haven’t been able to find any untoward side effects, and my log file is no longer reporting this error. I really appreciate your solution, and I’m looking forward to the Nextcloud 19 release in May, when scssphp is moved to its new location.

Thank you again!

buzz

@WhyYes: While this looked like a solution yesterday, this morning, my log file is filled with these errors again.

I really appreciate your effort, though! :slight_smile:

I don’t have the time to learn PHP, or I would try to fix this myself. May 21st isn’t that far away, I suppose.

Hi @buzz, yes, you’re right, that’s what happens if I don’t test everthing :sweat_smile:

Anyway, the reason is that my addition only checks if $args[2][1] is set for the remainder of that if statement, so the rest of that ill-written function can still throw null pointers around. So another dirty hack without knowing any side effects would be to bail out at the top when either $args[2] or $args[2][1] isn’t set:

if (!isset($args[2]) || !isset($args[2][1])) {
     return static::$nullString;
}

Again, it seems to work for me, but use at your own peril. I really can’t be bothered to look into PHP testing, sorry.

Thank you. This works for me too.

The odd thing is, strsplice() has been fixed back in August in version 1.0.3. of scssphp (https://github.com/scssphp/scssphp/commit/05a5d11ea7f68c52fdb6a5ca35cf46613b608445), while Nextcloud still uses version 0.7.6 (see src/Version.php in your scssphp folder).

It would be interesting to know what prevents Nextcloud to use an update of this dependency.

It would be interesting to know what prevents Nextcloud to use an update of this dependency.

The odd thing is, strsplice() has been fixed back in August in version 1.0.3. of scssphp

1.0.4 is the version with the fix and also breaking the styling.

So no fix for NC19?! I hope @WhyYes fix won’t cause problems until v20. :slight_smile:

1 Like

Fair enough.

Hello, @WhyYes,

Thanks again for the effort, but after updating with your latest code, I now receive errors on two lines of code in Compiler.php, instead of the single line previously:

Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#2887
Trying to access array offset on value of type null at /usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#2745

Again, thanks for the effort. It looks like this fix is now targeted for NC20, but I’m hoping for a NC19 backport at some point!

buzz

In my case it is one line flooding the php error log with

Trying to access array offset on value of type null at /var/www/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230

using NC 18.0.6 under ubuntu 18.04.4 with PHP 7.4.6

1 Like

I have exactly the same error and the same configuration as chrissi55.

1 Like

It is not working for me with NC 18.0.6, Fedora 32 Server Edition PHP 7.4.6
When I add the changes I get plenty of those errors:

[PHP] Error: Trying to access array offset on value of type int at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#327

After updating Nextcloud, the collabora/code Docker image, and the Nextcloud Collabora app, I no longer have this problem.

Operating system: Linux 5.7.2-arch1-1 #1 SMP PREEMPT Wed, 10 Jun 2020 20:36:24 +0000 x86_64

Webserver: nginx/1.19.0 (fpm-fcgi)

Database: mysql 10.4.13

PHP version: 7.4.7

Modules loaded: Core, date, libxml, openssl, pcre, zlib, ctype, dom, fileinfo, filter, hash, json, mbstring, pcntl, SPL, PDO, apcu, posix, readline, Reflection, session, SimpleXML, standard, tokenizer, xml, xmlreader, xmlwriter, mysqlnd, cgi-fcgi, bcmath, bz2, curl, exif, ftp, gd, gettext, gmp, iconv, imap, intl, mysqli, pdo_mysql, pdo_sqlite, pspell, snmp, sockets, sqlite3, tidy, xmlrpc, xsl, zip, apc, Phar, geoip, igbinary, imagick, pam, redis, smbclient, libsmbclient, Zend OPcache

Nextcloud version: 19.0.0 - 19.0.0.12

Good luck!

buzz

1 Like

For NC 19 but not 18? Because in NC 18 I still have those messages.