Skip to content

PHP 8 crash in GroupFolders trashbin when item has no extension (Undefined array key "extension")Β #4359

@fajarbs08

Description

@fajarbs08

Steps to reproduce

  1. Create a Group Folder (Team folder)
  2. Inside the Group Folder:
    • Create a directory or a file without extension (e.g. README)
  3. Delete the directory / file
  4. Open the Trashbin via web UI or via WebDAV (PROPFIND on /remote.php/dav/trashbin/*)

Expected behaviour

Group Folder trashbin should open normally and list all deleted items,
including directories and files without extensions.

Actual behaviour

The Group Folder trashbin fails to load and returns a PHP fatal error
when the trash contains directories or files without an extension.

Server configuration

Operating system: Linux
Web server: Apache
Database: PostgreSQL
PHP version: PHP 8.3
Nextcloud version: 32.0.5
Team folders version: groupfolders (shipped / custom_apps)
Updated from an older Nextcloud/ownCloud or fresh install: fresh install
Where did you install Nextcloud from: official Nextcloud package
Are you using external storage, if yes which one: local
Are you using encryption: no
Are you using an external user-backend, if yes which one: no

Client configuration

Browser: any (also reproducible via WebDAV)
Operating system: Linux

Logs

Web server error log

Web server error log PHP Notice: Undefined array key "extension" in custom_apps/groupfolders/lib/Trash/TrashBackend.php on line ~451

PHP Fatal error: Uncaught TypeError:
substr(): Argument #1 ($string) must be of type string, null given

Nextcloud log (data/nextcloud.log)

Nextcloud log

Error during WebDAV PROPFIND /remote.php/dav/trashbin/*

Undefined array key "extension"
substr(): Argument #1 ($string) must be of type string, null given

Stack trace points to:
custom_apps/groupfolders/lib/Trash/TrashBackend.php:~451

Browser log

Browser log

PROPFIND /remote.php/dav/trashbin/* β†’ 500 Internal Server Error

Additional information

  • The issue only occurs when the Group Folder trash contains:
    • directories (mimetype = httpd/unix-directory), or
    • files without a file extension
  • Database integrity is OK (no NULL values in name, original_location, or file_id)
  • Removing folder entries from oc_group_folders_trash immediately resolves the issue
  • Root cause appears to be assuming pathinfo()['extension'] always exists
  • pathinfo() does not return an extension key for directories or filenames without a dot
  • This leads to a PHP 8 fatal error when the value is later passed to substr()

A small defensive fix using $pathInfo['extension'] ?? '' and
$pathInfo['filename'] prevents the crash without changing behavior
for files that do have extensions.

Metadata

Metadata

Assignees

Labels

1. to developIssues that are ready for developmentbug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions