cms_pico icon indicating copy to clipboard operation
cms_pico copied to clipboard

1014 errors in the logs since 3. Juli 2024, 18:46:13 Undefined array key

Open kruthoff opened this issue 1 year ago • 10 comments

cms_pico produces many errors in nextcloud.log, such as

{"reqId":"KnV3So1DBNZHzppo8HZ9","level":3,"time":"2024-07-10T18:35:09+02:00","remoteAddr":"192.168.1.175","user":"<user>","app":"PHP","method":"GET","url":"/index.php/apps/cms_pico/pico_proxy/<site>/","message":"Undefined array key \"\" at /var/www/html/nextcloud/lib/private/AppFramework/Http.php#128","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0","version":"29.0.3.4","data":{"app":"PHP"}}

I'm running it with php-8.2. Does anybody know how this can be fixed? I assume it's not too complicated, but I'm not a php developer, unfortunately.

Any help is much appreciated.

kruthoff avatar Jul 10 '24 16:07 kruthoff

Please provide a full stacktrace from the logfile of that error.

PhrozenByte avatar Jul 12 '24 10:07 PhrozenByte

nextcloud-undefined-array-key [PHP] Error: Undefined array key "" at /var/www/html/nextcloud/lib/private/AppFramework/Http.php#128 GET /index.php/apps/cms_pico/pico_proxy/andreas_kruthoff/ from 194.195.253.114 by -- at 12.07.2024, 14:18:49

That's it.

kruthoff avatar Jul 12 '24 12:07 kruthoff

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1:

github-actions[bot] avatar Jul 20 '24 12:07 github-actions[bot]

Error handling for this case if the array key is undefined, or figure out why the key is undefined and define it, maybe.

kruthoff avatar Jul 21 '24 09:07 kruthoff

or figure out why the key is undefined and define it

You might figure that out, yes.

As I said, since I can't reproduce it and without you providing a full stacktrace, its literally impossible for me to find the root cause of this error thrown in Nextcloud's code. You might want to report the error in nextcloud/server, too; no matter what the app does, nextcloud/server should properly handle a non-existing key.

PhrozenByte avatar Jul 21 '24 11:07 PhrozenByte

How can I provide a full stack trace? In loglevel 0, I get some more messages, but I don't know if it helps.

{"reqId":"14GfWWNsSVqREQLM13gN","level":0,"time":"2024-07-21T18:07:32+02:00","remoteAddr":"192.168.1.175","user":"andreas","app":"cms_pico","method":"GET","url":"/apps/files/api/v1/stats","message":"/appinfo/app.php is deprecated, use \\OCP\\AppFramework\\Bootstrap\\IBootstrap on the application class instead.","userAgent":"Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36","version":"29.0.4.1","data":{"app":"cms_pico"}}

and

{"reqId":"lkOkRMpFGDdrvRSHRHLk","level":0,"time":"2024-07-21T18:01:07+02:00","remoteAddr":"192.168.1.175","user":"andreas","app":"PHP","method":"GET","url":"/index.php/apps/cms_pico/pico_proxy/andreas_kruthoff/","message":"trim(): Passing null to parameter #1 ($string) of type string is deprecated at /var/www/html/nextcloud/apps/cms_pico/vendor/symfony/yaml/Inline.php#49","userAgent":"Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36","version":"29.0.4.1","data":{"app":"PHP"}}
{"reqId":"lkOkRMpFGDdrvRSHRHLk","level":0,"time":"2024-07-21T18:01:07+02:00","remoteAddr":"192.168.1.175","user":"andreas","app":"PHP","method":"GET","url":"/index.php/apps/cms_pico/pico_proxy/andreas_kruthoff/","message":"Function strftime() is deprecated at /var/www/html/nextcloud/apps/cms_pico/vendor/picocms/pico/lib/Pico.php#1527","userAgent":"Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36","version":"29.0.4.1","data":{"app":"PHP"}}

kruthoff avatar Jul 21 '24 16:07 kruthoff

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1:

github-actions[bot] avatar Jul 29 '24 12:07 github-actions[bot]

I just recently updated from NC 27 to 30 and started seeing this issue. Dug into it and found that in [nextcloud apps directory]/cms_pico/lib/Http/PicoPageResoponse.php in the constructor, there is an if statement:

if ($page->is404Content()) {
       $this->setStatus(Http::STATUS_NOT_FOUND);
}

I added an else to set the status to STATUS_OK:

if ($page->is404Content()) {
    $this->setStatus(Http::STATUS_NOT_FOUND);
} else {
    $this->setStatus(Http::STATUS_OK);
}

This seems to have resolved the issue.

doftnet avatar Dec 17 '24 16:12 doftnet

Thanks @doftnet, reopening as bug now. However, please note that cms_pico isn't under active development right now and thus it's - as of now - unlikely that there's going to be a bugfix release (you can naturally still patch it yourself and keep using that self-patched version).

PhrozenByte avatar Dec 17 '24 17:12 PhrozenByte

I kinda figured that was the case. That if statement was added in my PR from 5 years ago so the least I could do is share a fix with the community.

doftnet avatar Dec 17 '24 17:12 doftnet