juliushaertl / apporder

Nextcloud app to enable sorting inside the app menu
GNU Affero General Public License v3.0
45 stars 9 forks source link

Error: Trying to access array offset on value of type null #91

Closed radoeka closed 4 years ago

radoeka commented 4 years ago

I get the following error in my nextcloud log:

[PHP] Error: Trying to access array offset on value of type null at .......nextcloud18.0.7/3rdparty/leafo/scssphp/src/Compiler.php#5230

GET /settings/admin/apporder

apporder version: 0.10.0

nextcloud-18.0.7 # ls -l 3rdparty/leafo/scssphp/src/Compiler.php
-rw-r--r-- 1 wwwrun www 143805 Jul 15 22:01 3rdparty/leafo/scssphp/src/Compiler.php

regel 5230 Compiler.php:

5215     protected function libStrSlice($args)
5216     {
5217         if (isset($args[2]) && $args[2][1] == 0) {
5218             return static::$nullString;
5219         }
5220 
5221         $string = $this->coerceString($args[0]);
5222         $stringContent = $this->compileStringContent($string);
5223 
5224         $start = (int) $args[1][1];
5225 
5226         if ($start > 0) {
5227             $start--;
5228         }
5229 
5230         $end    = (int) $args[2][1];
5231         $length = $end < 0 ? $end + 1 : ($end > 0 ? $end - $start : $end);

scssphp Version info:

nextcloud-18.0.7/3rdparty/leafo/scssphp/src # ls -l Compiler.php Version.php
-rw-r--r-- 1 wwwrun www 143805 Jul 15 22:01 Compiler.php
-rw-r--r-- 1 wwwrun www    312 Jul 15 22:01 Version.php

In Version.php:
class Version
{
    const VERSION = 'v0.7.6';
}

Anything that can be done about about the reported Error?

radoeka commented 4 years ago

Looks like that I found a solution for this in the nextcloud issue tracker. The 3rd party must be patched for this.

There are some issues involved:

In the end one of the issues refers to the commit that made it work:

I did not find an applyable patch, hence I created one myself:

diff -Naur src/Compiler.php src-new/Compiler.php
--- src/Compiler.php    2020-07-15 22:01:07.000000000 +0200
+++ src-new/Compiler.php        2020-08-11 19:30:48.279421680 +0200
@@ -5211,10 +5211,10 @@
         return new Node\Number(strlen($stringContent), '');
     }

-    protected static $libStrSlice = ['string', 'start-at', 'end-at'];
+    protected static $libStrSlice = ['string', 'start-at', 'end-at:-1'];
     protected function libStrSlice($args)
     {
-        if (isset($args[2]) && $args[2][1] == 0) {
+        if (isset($args[2]) && ! $args[2][1]) {
             return static::$nullString;
         }

@@ -5227,7 +5227,7 @@
             $start--;
         }

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

         $string[2] = $length

I'll close the issue, as the problem is with a 3rd party library.