Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninitialized string offset: 0 at Node.php#290 #10262

Closed
setar opened this issue Jul 16, 2018 · 30 comments
Closed

Uninitialized string offset: 0 at Node.php#290 #10262

setar opened this issue Jul 16, 2018 · 30 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug

Comments

@setar
Copy link

setar commented Jul 16, 2018

nextcloud 13.0.5 RC 2

error: Uninitialized string offset: 0 at Node.php#290

fix : nextcloud/lib/private/Files/Node/Node.php
in line 290 add !$path ||

fixed function:

        /**
         * @param string $path
         * @return string
         */
        protected function normalizePath($path) {
                if ($path === '' or $path === '/') {
                        return '/';
                }
                //no windows style slashes
                $path = str_replace('\\', '/', $path);
                //add leading slash
                 if (!$path || $path[0] !== '/') {
                        $path = '/' . $path;
                 }
                //remove duplicate slashes
                while (strpos($path, '//') !== false) {
                        $path = str_replace('//', '/', $path);
                }
                //remove trailing slash
                $path = rtrim($path, '/');

                return $path;
        }
@nextcloud-bot
Copy link
Member

GitMate.io thinks a possibly related issue is #6335 (Undefined offset: 2).

@MorrisJobke
Copy link
Member

@setar Do you mind to send this to us via pull request? Thanks a lot for finding it.

@setar
Copy link
Author

setar commented Jul 24, 2018

sorry, I do not want to do a fork project to fix one line

@MorrisJobke
Copy link
Member

@setar Do you have any chance to debug this a bit? Where is the null coming from?

diff --git a/lib/private/Files/Node/Node.php b/lib/private/Files/Node/Node.php
index d2232624b9..3b6857e64f 100644
--- a/lib/private/Files/Node/Node.php
+++ b/lib/private/Files/Node/Node.php
@@ -284,6 +284,10 @@ class Node implements \OCP\Files\Node {
 	 * @return string
 	 */
 	protected function normalizePath($path) {
+		if ($path === null) {
+			\OC::$server->getLogger()->logException(new \Exception(), ['app' => 'debug-empty-path']);
+			return '/';
+		}
 		if ($path === '' or $path === '/') {
 			return '/';
 		}

This should help to log the stack trace.

@jancborchardt
Copy link
Member

@setar no need to fork the project. :) Github makes this very easy to simply do it online:

  1. Go to the file at https://github.com/nextcloud/server/blob/master/lib/private/Files/Node/Node.php
  2. Click on the pencil icon in the top right to start editing
  3. Make your changes and put in a commit message
  4. Click the button below that to open a pull request :)

And that’s all 🎉

@setar
Copy link
Author

setar commented Jul 27, 2018

Thanks, its new knowledge for me :)

@Tanarri
Copy link

Tanarri commented Sep 17, 2018

Hi,
I have also those errors with 13.0.6.

I can do the fix like @jancborchardt mentioned, but I haven't the knowledge in PHP. So I think it would be better if someone do the fix, who know want he do.

@feutl
Copy link

feutl commented Sep 22, 2018

I am seeing the same errors on 13.0.6

@amicheals
Copy link

How do I make this change? under vi, it says it is a read only file.

@enoch85
Copy link
Member

enoch85 commented Sep 28, 2018

I see this on 14.0.1, fyi.

enoch85 pushed a commit that referenced this issue Sep 29, 2018
Signed-off-by: Daniel Hansson <daniel@hanssonit.se>
@enoch85
Copy link
Member

enoch85 commented Sep 29, 2018

I added a PR. Please review!

#11465

enoch85 pushed a commit that referenced this issue Sep 29, 2018
Signed-off-by: Daniel Hansson daniel@hanssonit.se
@MorrisJobke
Copy link
Member

I added a PR. Please review!

Okay - we should not fix the symptoms but actually the cause. In the proposed way the cause is simply hidden. 🙈

@ggeorgg
Copy link

ggeorgg commented Oct 8, 2018

Same problem here.
I just insterted the code snipped to trace this error down.
@MorrisJobke is the following information helpful?

Here one line raw data of my log file:

{
    "reqId": "W7vC5kUEp9I8jo5E8Aa2jAAAAA4",
    "level": 3,
    "time": "2018-10-08T20:49:44+00:00",
    "remoteAddr": "93.214.73.235",
    "user": "georg",
    "app": "debug-empty-path",
    "method": "PUT",
    "url": "/remote.php/dav/uploads/georg/2136506002/00000000",
    "message": {
        "Exception": "Exception",
        "Message": "",
        "Code": 0,
        "Trace": [
            {
                "file": "/var/www/nextcloud/lib/private/Files/Node/Folder.php",
                "line": 58,
                "function": "normalizePath",
                "class": "OC\\Files\\Node\\Node",
                "type": "->",
                "args": [
                    null
                ]
            },
            {
                "file": "/var/www/nextcloud/lib/private/Files/Node/Folder.php",
                "line": 133,
                "function": "getFullPath",
                "class": "OC\\Files\\Node\\Folder",
                "type": "->",
                "args": [
                    null
                ]
            },
            {
                "file": "/var/www/nextcloud/apps/files_fulltextsearch/lib/Service/FilesService.php",
                "line": 289,
                "function": "get",
                "class": "OC\\Files\\Node\\Folder",
                "type": "->",
                "args": [
                    null
                ]
            },
            {
                "file": "/var/www/nextcloud/apps/files_fulltextsearch/lib/Events/FilesEvents.php",
                "line": 74,
                "function": "getFileFromPath",
                "class": "OCA\\Files_FullTextSearch\\Service\\FilesService",
                "type": "->",
                "args": [
                    "georg",
                    null
                ]
            },
            {
                "file": "/var/www/nextcloud/apps/files_fulltextsearch/lib/Hooks/FilesHooks.php",
                "line": 67,
                "function": "onNewFile",
                "class": "OCA\\Files_FullTextSearch\\Events\\FilesEvents",
                "type": "->",
                "args": [
                    null
                ]
            },
            {
                "file": "/var/www/nextcloud/lib/private/legacy/hook.php",
                "line": 106,
                "function": "onNewFile",
                "class": "OCA\\Files_FullTextSearch\\Hooks\\FilesHooks",
                "type": "::",
                "args": [
                    {
                        "path": null
                    }
                ]
            },
            {
                "file": "/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php",
                "line": 320,
                "function": "emit",
                "class": "OC_Hook",
                "type": "::",
                "args": [
                    "OC_Filesystem",
                    "post_create",
                    {
                        "path": null
                    }
                ]
            },
            {
                "file": "/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php",
                "line": 252,
                "function": "emitPostHooks",
                "class": "OCA\\DAV\\Connector\\Sabre\\File",
                "type": "->",
                "args": [
                    false
                ]
            },
            {
                "file": "/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php",
                "line": 156,
                "function": "put",
                "class": "OCA\\DAV\\Connector\\Sabre\\File",
                "type": "->",
                "args": [
                    null
                ]
            },
            {
                "file": "/var/www/nextcloud/apps/dav/lib/Upload/UploadFolder.php",
                "line": 39,
                "function": "createFile",
                "class": "OCA\\DAV\\Connector\\Sabre\\Directory",
                "type": "->",
                "args": [
                    "00000000",
                    null
                ]
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
                "line": 1096,
                "function": "createFile",
                "class": "OCA\\DAV\\Upload\\UploadFolder",
                "type": "->",
                "args": [
                    "00000000",
                    null
                ]
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
                "line": 529,
                "function": "createFile",
                "class": "Sabre\\DAV\\Server",
                "type": "->",
                "args": [
                    "uploads/georg/2136506002/00000000",
                    null,
                    null
                ]
            },
            {
                "function": "httpPut",
                "class": "Sabre\\DAV\\CorePlugin",
                "type": "->",
                "args": [
                    {
                        "absoluteUrl": "https://nextcloud.example.de/remote.php/dav/uploads/georg/2136506002/00000000",
                        "__class__": "Sabre\\HTTP\\Request"
                    },
                    {
                        "__class__": "Sabre\\HTTP\\Response"
                    }
                ]
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/event/lib/EventEmitterTrait.php",
                "line": 105,
                "function": "call_user_func_array",
                "args": [
                    [
                        {
                            "__class__": "Sabre\\DAV\\CorePlugin"
                        },
                        "httpPut"
                    ],
                    [
                        {
                            "absoluteUrl": "https://nextcloud.example.de/remote.php/dav/uploads/georg/2136506002/00000000",
                            "__class__": "Sabre\\HTTP\\Request"
                        },
                        {
                            "__class__": "Sabre\\HTTP\\Response"
                        }
                    ]
                ]
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
                "line": 479,
                "function": "emit",
                "class": "Sabre\\Event\\EventEmitter",
                "type": "->",
                "args": [
                    "method:PUT",
                    [
                        {
                            "absoluteUrl": "https://nextcloud.example.de/remote.php/dav/uploads/georg/2136506002/00000000",
                            "__class__": "Sabre\\HTTP\\Request"
                        },
                        {
                            "__class__": "Sabre\\HTTP\\Response"
                        }
                    ]
                ]
            },
            {
                "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
                "line": 254,
                "function": "invokeMethod",
                "class": "Sabre\\DAV\\Server",
                "type": "->",
                "args": [
                    {
                        "absoluteUrl": "https://nextcloud.example.de/remote.php/dav/uploads/georg/2136506002/00000000",
                        "__class__": "Sabre\\HTTP\\Request"
                    },
                    {
                        "__class__": "Sabre\\HTTP\\Response"
                    }
                ]
            },
            {
                "file": "/var/www/nextcloud/apps/dav/lib/Server.php",
                "line": 293,
                "function": "exec",
                "class": "Sabre\\DAV\\Server",
                "type": "->",
                "args": []
            },
            {
                "file": "/var/www/nextcloud/apps/dav/appinfo/v2/remote.php",
                "line": 35,
                "function": "exec",
                "class": "OCA\\DAV\\Server",
                "type": "->",
                "args": []
            },
            {
                "file": "/var/www/nextcloud/remote.php",
                "line": 163,
                "args": [
                    "/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"
                ],
                "function": "require_once"
            }
        ],
        "File": "/var/www/nextcloud/lib/private/Files/Node/Node.php",
        "Line": 288,
        "CustomMessage": "--"
    },
    "userAgent": "Mozilla/5.0 (Windows) mirall/2.3.2 (build 1) (Nextcloud)",
    "version": "14.0.1.1"
}

And here an image of my nextcloud log section:
grafik

Note: I don't know what the other two error messages are about, but for now, just ignore them. (Or give me a hint where they come from, because they are really spamming my log file :) )

Server configuration detail

Operating system: Linux 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64

Webserver: Apache/2.4.29 (Ubuntu) (fpm-fcgi)

Database: pgsql PostgreSQL 10.5 (Ubuntu 10.5-0ubuntu0.18.04) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0, 64-bit

PHP version:

7.2.10-0ubuntu0.18.04.1
Modules loaded: Core, date, libxml, openssl, pcre, zlib, filter, hash, Reflection, SPL, sodium, session, standard, cgi-fcgi, redis, PDO, xml, bz2, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, gmp, iconv, imagick, imap, intl, json, ldap, exif, pdo_pgsql, pgsql, Phar, posix, readline, shmop, SimpleXML, smbclient, soap, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xmlreader, xmlwriter, xsl, zip, libsmbclient, Zend OPcache

Nextcloud version: 14.0.1 - 14.0.1.1

Updated from an older Nextcloud/ownCloud or fresh install:

Freh install with github.com/nextcloud/vm script

Where did you install Nextcloud from: unknown

Signing status

Array
(
)

List of activated apps
Enabled:
 - accessibility: 1.0.1
 - activity: 2.7.0
 - calendar: 1.6.2
 - caniupdate: 0.2.0
 - cloud_federation_api: 0.0.1
 - comments: 1.4.0
 - contacts: 2.1.6
 - dav: 1.6.0
 - federatedfilesharing: 1.4.0
 - federation: 1.4.0
 - files: 1.9.0
 - files_fulltextsearch: 1.0.1
 - files_pdfviewer: 1.3.2
 - files_sharing: 1.6.2
 - files_texteditor: 2.6.0
 - files_trashbin: 1.4.1
 - files_versions: 1.7.1
 - files_videoplayer: 1.3.0
 - firstrunwizard: 2.3.0
 - fulltextsearch: 1.0.1
 - fulltextsearch_elasticsearch: 1.0.1
 - gallery: 18.1.0
 - issuetemplate: 0.4.0
 - logreader: 2.0.0
 - lookup_server_connector: 1.2.0
 - nextcloud_announcements: 1.3.0
 - notifications: 2.2.1
 - oauth2: 1.2.1
 - onlyoffice: 2.0.4
 - password_policy: 1.4.0
 - previewgenerator: 1.1.0
 - provisioning_api: 1.4.0
 - serverinfo: 1.4.0
 - sharebymail: 1.4.0
 - support: 1.0.0
 - survey_client: 1.2.0
 - systemtags: 1.4.0
 - tasks: 0.9.7
 - theming: 1.5.0
 - twofactor_backupcodes: 1.3.1
 - updatenotification: 1.4.1
 - workflowengine: 1.4.0
Disabled:
 - admin_audit
 - encryption
 - files_external
 - user_external
 - user_ldap

Configuration (config/config.php)
{
    "passwordsalt": "***REMOVED SENSITIVE VALUE***",
    "secret": "***REMOVED SENSITIVE VALUE***",
    "trusted_domains": [
        "localhost",
        "XXX.XXX.XXX.XX",
        "nextcloud.example.de",
        "nextcloud.example.de"
    ],
    "datadirectory": "***REMOVED SENSITIVE VALUE***",
    "dbtype": "pgsql",
    "version": "14.0.1.1",
    "overwrite.cli.url": "https:\/\/nextcloud.example.de\/",
    "dbname": "***REMOVED SENSITIVE VALUE***",
    "dbhost": "***REMOVED SENSITIVE VALUE***",
    "dbport": "",
    "dbtableprefix": "oc_",
    "dbuser": "***REMOVED SENSITIVE VALUE***",
    "dbpassword": "***REMOVED SENSITIVE VALUE***",
    "installed": true,
    "instanceid": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpmode": "smtp",
    "log_rotate_size": "10485760",
    "memcache.local": "\\OC\\Memcache\\Redis",
    "filelocking.enabled": true,
    "memcache.distributed": "\\OC\\Memcache\\Redis",
    "memcache.locking": "\\OC\\Memcache\\Redis",
    "redis": {
        "host": "***REMOVED SENSITIVE VALUE***",
        "port": 0,
        "timeout": 0.5,
        "dbindex": 0,
        "password": "***REMOVED SENSITIVE VALUE***"
    },
    "htaccess.RewriteBase": "\/",
    "loglevel": "2",
    "log_type": "file",
    "logfile": "\/mnt\/ncdata\/nextcloud.log",
    "logtimezone": "Etc\/UTC",
    "enable_previews": true,
    "preview_libreoffice_path": "\/usr\/bin\/libreoffice",
    "maintenance": false,
    "onlyoffice": {
        "verify_peer_off": true
    },
    "mail_from_address": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpauthtype": "LOGIN",
    "mail_domain": "***REMOVED SENSITIVE VALUE***",
    "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpport": "587",
    "mail_smtpauth": 1,
    "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
    "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
    "mail_smtpsecure": "tls"
}

Are you using external storage, if yes which one: local/smb/sftp/...

No

Are you using encryption:

No

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...

Webdav

Client configuration

Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0

@MorrisJobke
Copy link
Member

@icewind1991 @rullzer looks suspicious. Any idea where this is coming from?

Maybe @danielkesselberg wants to dig into this 😉

@Githopp192
Copy link

i did the upgrade from 13.0.6 to 13.0.7 on 20th of Octobre 18. Since then i see those message into the nc-log -->

Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 23 minutes ago
Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 23 minutes ago
Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290

@enoch85
Copy link
Member

enoch85 commented Oct 23, 2018

Just a guess here, but I've seen numerous of errors when using the Full Text Search app. Not saying that it's the cause for this, but if everyone could confirm or deny if they use it or not maybe we have something to dig into.

I use it.

@ggeorgg
Copy link

ggeorgg commented Oct 23, 2018

I also use it.

@enoch85
Copy link
Member

enoch85 commented Oct 23, 2018

@setar @Tanarri @amicheals @feutl Do you use Full Text Search?

@Githopp192
Copy link

There are two apps about .. the "Full text search" and the "Full text search - Files" .. both are activated on my Cloud. I don't know if the " "#290" is indicating the Line number into the script .. when yes .. then it would be this function, which could be responsible for ..

protected function normalizePath($path) {
if ($path === '' or $path === '/') {
return '/';
}
//no windows style slashes
$path = str_replace('\', '/', $path);
//add leading slash
if ($path[0] !== '/') {
$path = '/' . $path;
}
//remove duplicate slashes
while (strpos($path, '//') !== false) {
$path = str_replace('//', '/', $path);
}
//remove trailing slash
$path = rtrim($path, '/');

            return $path;
    }

@ggeorgg
Copy link

ggeorgg commented Oct 23, 2018

We already know that it is this function where the error comes up. The question is, where does it come from.
Therefore I modified the file with this function. (Have a look here)
You can see the stack trace. When I remember correctly, I wanted to upload a huge amount of data with the nextcloud client on my windows 10.
This is for example why we have this line here: "file": "/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php" in the stack trace.
A bit later we see: "file": "/var/www/nextcloud/lib/private/legacy/hook.php",
and then the fulltextsearch app comes in: "file": "/var/www/nextcloud/apps/files_fulltextsearch/lib/Events/FilesEvents.php",
So I think @enoch85 is right. It has to do something with the fulltextsearch. @daita Could you have a look? :)

@ArtificialOwl
Copy link
Member

ArtificialOwl commented Oct 23, 2018

seems to be from above fulltextsearch: the path from the broadcasted event is null.

But I wrote a fix for files_fulltextsearch (NC14) to ignore events when the path is null.
Should be fine, but I'll do more test tomorrow:

Note: still would be interesting to understand why the path is null

@ArtificialOwl
Copy link
Member

Please upgrade your files_fulltextsearch to 1.1.0 (NC14)

@Githopp192
Copy link

i did the upgrade for: (i'm on NC 13.0.7)
Full text search 1.0.3
Full text search - Files 1.0.3

The Log still will be flooded ..

Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 3 minutes ago
Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 3 minutes ago
Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 3 minutes ago
Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 3 minutes ago
Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 3 minutes ago
Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 3 minutes ago
Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 3 minutes ago
Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 4 minutes ago
Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 4 minutes ago
Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 4 minutes ago
Error PHP Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#290 4 minutes ago

Thx for investigating ..

@Githopp192
Copy link

Thx for the hint upgrading the app .. currently i'm running nc 13.0.7 .. and Version 1.1.0 is not compatible with version 1.3, i think ( Required Nextcloud versions | >=14.0.0,<15.0.0 )

@skjnldsv skjnldsv added the 0. Needs triage Pending check for reproducibility or if it fits our roadmap label Jun 12, 2019
@skjnldsv
Copy link
Member

As the version of the software you've reported this for has reached end of life, I will close this ticket. If this is still happening after an upgrade to the latest version, feel free to reopen

@Wotisrv
Copy link

Wotisrv commented May 4, 2020

Hei I am using NC 18.0.4. I currently activate ransomware recovery app and suddenly I get all those error messages:

Uninitialized string offset: 0 at /var/www/html/nextcloud/lib/private/Files/Node/Node.php#307
Undefined index: dirname at /var/www/html/nextcloud/apps/ransomware_detection/lib/Monitor.php#260

@paschaef
Copy link

paschaef commented May 6, 2020

I observed the same issue as @Wotisrv, also with NC 18.0.4 and ransomware recovery app.

@blitzdesigner
Copy link

I second this, get my logfile spammed with these three errors:

Error PHP Uninitialized string offset: 0 at /var/www/path_to_nextcloud/lib/private/Files/Node/Node.php#307

Error PHP Undefined index: dirname at /var/www/path_to_nextcloud/apps/ransomware_detection/lib/Monitor.php#260

Error PHP Uninitialized string offset: 0 at /var/www/path_to_nextcloud/lib/private/Files/Node/Node.php#307

@tomynr1
Copy link

tomynr1 commented Jun 12, 2020

Same problem as last three comments.

NC 19.0.0 installed on Ubuntu 18.04

@jonathanmmm
Copy link

reopened in #23229
Still here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug
Projects
None yet
Development

No branches or pull requests