Server: value of type null for Compiler.php

Created on 19 Jan 2020  路  29Comments  路  Source: nextcloud/server

Hello

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

On a fresh install of nextcloud 18. Any idea ?

[root@SRV]# php -v
PHP 7.4.1 (cli) (built: Dec 17 2019 16:35:58) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.1, Copyright (c), by Zend Technologies

The nextcloud repo shows a dependency on scssphp 0.7.2.
Maybe an update is needed, since it's an old version...

https://github.com/scssphp/scssphp/issues/73

0. Needs triage bug

Most helpful comment

All 29 comments

+1

FWIW, while nextcloud/3rdparty/pull/361 upgrades leafo/scssphp to 0.8.4, the 18.0.1-1 release still ships with v0.7.6:

````
$ pacman -Qo ../nextcloud/3rdparty/leafo/scssphp/src/Version.php
[...]/nextcloud/3rdparty/leafo/scssphp/src/Version.php is owned by nextcloud 18.0.1-1

$ grep VER ../nextcloud/3rdparty/leafo/scssphp/src/Version.php
const VERSION = 'v0.7.6';

$ php-fpm -v | grep ^P
PHP 7.4.2 (fpm-fcgi) (built: Jan 21 2020 18:16:58)
````
Will this be merged into v18 at all or only in v19?

In my setup (archlinux, nginx and php-fpm with pools, all packages up-to-date) the file
/usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php
had the following _hardened_ permissions
root:http, 640

As a temporary workaround setting
chown http:http '/usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php'
and restarting the webserver and php-fpm solves the issue.

It seems the recommendation of hardening the permissions the was removed entirely.
https://github.com/nextcloud/documentation/pull/431.

In my setup (archlinux, nginx and php-fpm with pools, all packages up-to-date) the file
/usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php
had the following _hardened_ permissions
root:http, 640

As a temporary workaround setting
chown http:http '/usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php'
and restarting the webserver and php-fpm solves the issue.

It seems the recommendation of hardening the permissions the was removed entirely.
nextcloud/documentation#431.

Not in my case. That file is already with good owner.

In my setup (archlinux, nginx and php-fpm with pools, all packages up-to-date) the file
/usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php
had the following _hardened_ permissions
root:http, 640
As a temporary workaround setting
chown http:http '/usr/share/webapps/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php'
and restarting the webserver and php-fpm solves the issue.
It seems the recommendation of hardening the permissions the was removed entirely.
nextcloud/documentation#431.

Not in my case. That file is already with good owner.

Same for me. On CentOS 8 with fresh install of NC 18 (PHP 7.4.2) I got the same error but Compiler.php has permissions apache:apache, 640

I have the same issue, openSUSE Tumbleweed, PHP 7.4.2, NC 18.0.0, 18.0.1, correct owner of Compiler.php

Edit:
I've replaced 3rdparty/leafo/scssphp v0.7.7 with v0.8.4

Let's see what happens next.

I have the same issue, openSUSE Tumbleweed, PHP 7.4.2, NC 18.0.0, 18.0.1, correct owner of Compiler.php

Edit:
I've replaced 3rdparty/leafo/scssphp v0.7.7 with v0.8.4

Let's see what happens next.

So upgrading scssphp to v0.8.4 you got rid of those PHP log messages?

So upgrading scssphp to v0.8.4 you got rid of those PHP log messages?

I made it about two hours ago. No errors so far, but there is not much traffic in the cloud currently.

So upgrading scssphp to v0.8.4 you got rid of those PHP log messages?

I made it about two hours ago. No errors so far, but there is not much traffic in the cloud currently.

Ok, nice try. Please report after 6-8 hours if error is spamming again

No errors. Everything seems to be fine now.

Edit.

Sorry guys, the errors are there again. But they refer to another line of Compiler.php:

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

If you want to patch this for 18:

nextcloud/3rdparty#386

19100


Excuse me, @kesselb , how can we do it?

/srv/www/nextcloud/3rdparty # wget https://patch-diff.githubusercontent.com/raw/nextcloud/3rdparty/pull/386.patch
/srv/www/nextcloud/3rdparty # git apply --check 386.patch
error: .gitignore: No such file or directory
error: patch failed: composer.json:23
error: composer.json: patch does not apply
error: patch failed: composer.lock:4
error: composer.lock: patch does not apply
error: patch failed: composer/autoload_classmap.php:1180
error: composer/autoload_classmap.php: patch does not apply
error: patch failed: composer/autoload_static.php:1641
error: composer/autoload_static.php: patch does not apply
error: patch failed: composer/installed.json:1641
error: composer/installed.json: patch does not apply
error: patch failed: leafo/scssphp/README.md:1
error: leafo/scssphp/README.md: patch does not apply
error: patch failed: leafo/scssphp/composer.json:1
error: leafo/scssphp/composer.json: patch does not apply
error: patch failed: leafo/scssphp/scss.inc.php:1
error: leafo/scssphp/scss.inc.php: patch does not apply
error: patch failed: leafo/scssphp/src/Block.php:64
error: leafo/scssphp/src/Block.php: patch does not apply
error: leafo/scssphp/src/Cache.php: No such file or directory
error: patch failed: leafo/scssphp/src/Compiler.php:2
error: leafo/scssphp/src/Compiler.php: patch does not apply
error: patch failed: leafo/scssphp/src/Formatter/Compressed.php:63
error: leafo/scssphp/src/Formatter/Compressed.php: patch does not apply
error: patch failed: leafo/scssphp/src/Formatter/Crunched.php:61
error: leafo/scssphp/src/Formatter/Crunched.php: patch does not apply
error: patch failed: leafo/scssphp/src/Parser.php:2
error: leafo/scssphp/src/Parser.php: patch does not apply
error: leafo/scssphp/src/SourceMap/Base64.php: No such file or directory
error: leafo/scssphp/src/SourceMap/Base64VLQ.php: No such file or directory
error: patch failed: leafo/scssphp/src/SourceMap/SourceMapGenerator.php:61
error: leafo/scssphp/src/SourceMap/SourceMapGenerator.php: patch does not apply
error: patch failed: leafo/scssphp/src/Version.php:18
error: leafo/scssphp/src/Version.php: patch does not apply
error: patch failed: composer.json:35
error: composer.json: patch does not apply
error: patch failed: composer.lock:4
error: composer.lock: patch does not apply
error: patch failed: composer/installed.json:3425
error: composer/installed.json: patch does not apply
error: scssphp/scssphp/README.md: No such file or directory
error: scssphp/scssphp/src/Cache.php: No such file or directory
error: scssphp/scssphp/src/Compiler.php: No such file or directory
error: scssphp/scssphp/src/Parser.php: No such file or directory
error: scssphp/scssphp/src/Version.php: No such file or directory

Probably easier to use PHP 7.3 until this fix has landed in 18. I guess you have to place the dependency in 3rdparty, remove leafo/scsphp, bump the autoloader and replace the usage of the library with the new one. I don't know why applying the patch is not possible. Maybe the released artifact looks different.

Unfortunately, there is no possibility to downgrade PHP to 7.3 on openSUSE Tumbleweed. There is no such a package in the repository. This is the openSUSE policy -- no obsolete packages.

I can downgrade on FreeBSD 12.1 but if thats just a problem in nextcloud I'll wait then for a fix...

After upgrading to 18.0.2.2 the issue still persists.

I guess it won't be fixed until NC 19 Release: 21-05-2020

Maintenance and Release Schedule 路 nextcloud/server Wiki 路 GitHub

Looks like. Automated backport of the dependency update failed. It's definitely fixed with Nextcloud 19.

These error messages are really annoying.
Can instead of the whole submodule, the single fixing commit please be backported to v18?
https://github.com/scssphp/scssphp/commit/05a5d11ea7f68c52fdb6a5ca35cf46613b608445

Can instead of the whole submodule, the single fixing commit please be backported to v18?

With what version of NC does it work? It does not work with 18.0.2.2

@cgzones , that commit does not work with 18.0.2.2 either. I'll upgrade to 18.0.3 and try again.

And it does not work with 18.0.3.0 either. The browser shows Internal Server Error. And after I return the old Compiler.php, I can see the following errors in the log:

[index] Error: ParseError: syntax error, unexpected ':', expecting ']'

 0. /srv/www/nextcloud/lib/composer/composer/ClassLoader.php line 322
    Composer\Autoload\includeFile("/srv/www/nextcl ... p")
 1. <<closure>>
    Composer\Autoload\ClassLoader->loadClass("Leafo\\ScssPhp\\Compiler")
 2. /srv/www/nextcloud/apps/theming/lib/Util.php line 96
    spl_autoload_call("Leafo\\ScssPhp\\Compiler")
 3. /srv/www/nextcloud/apps/theming/lib/Util.php line 83
    OCA\Theming\Util->calculateLuminance("#0082c9")
 4. /srv/www/nextcloud/apps/theming/lib/Capabilities.php line 80
    OCA\Theming\Util->elementColor("#0082c9")
 5. /srv/www/nextcloud/lib/private/CapabilitiesManager.php line 71
    OCA\Theming\Capabilities->getCapabilities()
 6. /srv/www/nextcloud/lib/private/Template/JSConfigHelper.php line 177
    OC\CapabilitiesManager->getCapabilities()
 7. /srv/www/nextcloud/lib/private/TemplateLayout.php line 190
    OC\Template\JSConfigHelper->getConfig()
 8. /srv/www/nextcloud/lib/private/legacy/template.php line 184
    OC\TemplateLayout->__construct("user", "files")
 9. /srv/www/nextcloud/lib/public/AppFramework/Http/TemplateResponse.php line 167
    OC_Template->fetchPage({usedSpacePercen ... ]})
10. /srv/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 123
    OCP\AppFramework\Http\TemplateResponse->render()
11. /srv/www/nextcloud/lib/private/AppFramework/App.php line 125
    OC\AppFramework\Http\Dispatcher->dispatch(OCA\Files\Controller\ViewController {}, "index")
12. /srv/www/nextcloud/lib/private/AppFramework/Routing/RouteActionHandler.php line 47
    OC\AppFramework\App::main("OCA\\Files\\Controller\\ViewController", "index", OC\AppFramework\ ... {}, {_route: "files.view.index"})
13. <<closure>>
    OC\AppFramework\Routing\RouteActionHandler->__invoke({_route: "files.view.index"})
14. /srv/www/nextcloud/lib/private/Route/Router.php line 299
    call_user_func(OC\AppFramework\ ... {}, {_route: "files.view.index"})
15. /srv/www/nextcloud/lib/base.php line 1008
    OC\Route\Router->match("/apps/files/")
16. /srv/www/nextcloud/index.php line 38
    OC::handleRequest()

Oops, my bad.

I typed 'end-at':-1 instead of 'end-at:-1'

Thank you, @cgzones , it works now! I don't know about the value of type null issue yet, but there are no errors with Compiler.php itself.

I have a couple of errors like this now:

[PHP] Error: Trying to access array offset on value of type bool at /srv/www/nextcloud/apps/files_versions/lib/Storage.php#654

at 2020-03-26T14:40:02+03:00

[PHP] Error: Trying to access array offset on value of type bool at /srv/www/nextcloud/apps/files_versions/lib/Storage.php#653

at 2020-03-26T14:40:02+03:00

The old errors seem to have disappeared.

Fixed with #20794

No upgrade of scssphp for 18.0.5
It seems next upgrade will be merged for NC19. #20794

This message comes up when opening a document with OnlyOffice.

[PHP 7.4] Error: Trying to access array offset on value of type null at /var/www/html/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230

{"reqId":"XuEu9lh17DyUmWFmXoK0-QAAANc","level":3,"time":"2020-06-10T21:05:27+02:00","remoteAddr":"xx.xx.xx.xx","user":"XXXX","app":"PHP","method":"GET","url":"/index.php/settings/user","message":"Trying to access array offset on value of type null at /var/www/html/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0","version":"18.0.6.0","id":"5ee12efc2a252"}

Also reporting the same error message in my logs, but even without opening a documents. My error log is showing this 50+ times per second:
{"reqId":"ddZgZXJOpg8vwwbhKb73","level":3,"time":"2020-06-21T17:28:41+00:00","remoteAddr":"xxx.xxx.xxx.xxx","user":"USER","app":"PHP","method":"GET","url":"/index.php/apps/files/","message":"Trying to access array offset on value of type null at /var/www/nextcloud/3rdparty/leafo/scssphp/src/Compiler.php#5230","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:77.0) Gecko/20100101 Firefox/77.0","version":"18.0.6.0"}

Was this page helpful?
0 / 5 - 0 ratings