[Bug]: Unused DateTimeImmutable::modify() return value in CalDavBackend.php generates PHP warning
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 78/100
Research direction
The warning points to apps/dav/lib/CalDAV/CalDavBackend.php at line 3437. Read the surrounding date-handling code first and determine whether the DateTimeImmutable::modify() result should be retained or intentionally ignored. Done means the PHP warning is eliminated without changing the intended CalDAV behavior; run the relevant DAV or CalDAV checks available in the repository.
Written by the indexing model from the issue text.
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
This warning has been captured directly from the nextcloud logs:
"The return value of method DateTimeImmutable::modify() should either be used or intentionally ignored by casting it as (void), as DateTimeImmutable::modify() does not modify the object itself at /var/www/nextcloud/apps/dav/lib/CalDAV/CalDavBackend.php#3437"
Because PHP Manual for DateTimeImmutable::modify returns a brand-new object instead of changing the original one, calling it without using the result is usually a coding mistake.
Maybe it could be fixed by changing
$date->modify('+1 day');
to
$date = $date->modify('+1 day'); so you actually save the changed date.
Steps to reproduce
- Every time the function is called (when webdav is used).
Expected behavior
I expect no warning is generated whenever the library is used.
Nextcloud Server version
34
Operating system
Other
PHP engine version
PHP 8.5
Web server
Apache (supported)
Database engine version
PostgreSQL
Is this bug present after an update or on a fresh install?
Updated from a MINOR version (ex. 32.0.1 to 32.0.2)
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
{
"system": {
"instanceid": "***REMOVED SENSITIVE VALUE***",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"***REMOVED SENSITIVE VALUE***",
"***REMOVED SENSITIVE VALUE***"
],
"allowed_admin_ranges": [
"X.X.X.X\/24"
],
"trusted_proxies": "***REMOVED SENSITIVE VALUE***",
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
"dbtype": "pgsql",
"version": "34.0.2.1",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbport": "",
"dbtableprefix": "oc_",
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"ldapIgnoreNamingRules": false,
"ldapUserCleanupInterval": 51,
"ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory",
"mail_from_address": "***REMOVED SENSITIVE VALUE***",
"mail_smtpmode": "smtp",
"mail_domain": "***REMOVED SENSITIVE VALUE***",
"default_phone_region": "ES",
"maintenance": false,
"theme": "",
"loglevel": 2,
"onlyoffice": {
"verify_peer_off": true
},
"mail_smtphost": "***REMOVED SENSITIVE VALUE***",
"updater.release.channel": "stable",
"trashbin_retention_obligation": "10, 30",
"mysql.utf8mb4": true,
"memcache.local": "\\OC\\Memcache\\Redis",
"memcache.locking": "\\OC\\Memcache\\Redis",
"memcache.distributed": "\\OC\\Memcache\\Redis",
"redis": {
"host": "***REMOVED SENSITIVE VALUE***",
"dbindex": 0,
"port": 6379,
"timeout": 0
},
"app_install_overwrite": {
"0": "passman",
"1": "bruteforcesettings",
"2": "files_markdown",
"4": "libresign",
"5": "twofactor_email",
"6": "socialsharing_facebook"
},
"memories.vod.path": "\/var\/www\/nextcloud\/apps\/memories\/bin-ext\/go-vod-amd64",
"memories.vod.ffmpeg": "\/usr\/bin\/ffmpeg",
"memories.vod.ffprobe": "\/usr\/bin\/ffprobe",
"memories.vod.disable": false,
"memories.vod.vaapi": true,
"mail_sendmailmode": "smtp",
"memories.db.triggers.fcu": true,
"maintenance_window_start": 1,
"preview_max_x": 1024,
"preview_max_y": 1024,
"jpeg_quality": 80,
"enabledPreviewProviders": [
"OC\\Preview\\Imaginary"
],
"preview_imaginary_url": "***REMOVED SENSITIVE VALUE***",
"files.chunked_upload.max_size": 10485760,
"mail_smtpport": "25",
"memories.gis_type": 2,
"memories.exiftool_no_local": true,
"serverid": "10"
}
}
List of activated Apps
Enabled:
- activity: 7.0.0
- admin_audit: 1.24.0
- announcementcenter: 7.4.1
- app_api: 34.0.0
- approval: 3.3.1
- appstore: 1.0.0
- bruteforcesettings: 7.0.0
- calendar: 6.5.1
- camerarawpreviews: 1.1.2
- circles: 34.0.0
- cloud_federation_api: 1.18.0
- comments: 1.24.0
- contacts: 8.7.4
- contactsinteraction: 1.15.0
- dav: 1.39.0
- deck: 1.18.3
- drawio: 4.3.5
- epubviewer: 1.9.7
- federatedfilesharing: 1.24.0
- federation: 1.24.0
- files: 2.6.0
- files_accesscontrol: 5.0.0
- files_automatedtagging: 5.0.0
- files_downloadlimit: 5.2.0
- files_external: 1.26.0
- files_lock: 34.0.1
- files_pdfviewer: 7.0.0-dev.0
- files_reminders: 1.7.0
- files_retention: 5.0.0
- files_sharing: 1.26.0
- files_trashbin: 1.24.0
- files_versions: 1.27.0
- firstrunwizard: 7.0.0-dev.0
- forms: 5.3.5
- groupfolders: 22.0.5
- logreader: 7.0.0
- lookup_server_connector: 1.22.0
- memories: 8.1.0
- nextcloud_announcements: 6.0.0
- notes: 6.0.1
- notifications: 7.0.0-dev.1
- notify_push: 1.3.5
- oauth2: 1.22.0
- office: 1.0.0
- onlyoffice: 10.1.2
- password_policy: 6.0.0-dev.0
- photos: 7.0.0
- polls: 9.1.4
- previewgenerator: 5.14.0
- privacy: 6.0.0-dev.1
- profile: 1.3.0
- provisioning_api: 1.24.0
- quota_warning: 1.24.0
- recommendations: 7.0.0
- related_resources: 5.0.0-dev.0
- serverinfo: 6.0.0
- settings: 1.17.0
- sharebymail: 1.24.0
- socialsharing_email: 4.1.0
- socialsharing_facebook: 4.1.0
- spreed: 24.0.3
- support: 6.0.0
- survey_client: 6.0.0-dev.0
- suspicious_login: 12.0.0-dev.0
- systemtags: 1.24.0
- tasks: 0.18.1
- terms_of_service: 4.7.1
- text: 8.0.0
- theming: 2.9.0
- twofactor_backupcodes: 1.23.0
- twofactor_email: 3.3.0
- twofactor_totp: 16.0.0
- twofactor_webauthn: 2.7.0
- updatenotification: 1.24.0
- user_ldap: 1.25.0
- user_status: 1.14.0
- viewer: 7.0.0-dev.0
- weather_status: 1.14.0
- webhook_listeners: 1.6.0
- workflowengine: 2.16.0
Disabled:
- dashboard: 7.14.0 (installed 6.0.0)
- encryption: 2.22.0
- files_markdown: 2.4.1 (installed 2.4.1)
- files_rightclick: 0.15.1 (installed 1.6.0)
- impersonate: 5.0.0 (installed 5.0.0)
- integration_mattermost: 3.1.0 (installed 3.1.0)
- integration_overleaf: 2.0.1 (installed 2.0.1)
- jitsi: 0.19.0 (installed 0.19.0)
- maps: 1.7.1 (installed 1.7.1)
- tables: 2.2.0 (installed 2.2.0)
- talk_matterbridge: 1.34.1026000 (installed 1.34.1026000)
- testing: 1.23.0
- twofactor_nextcloud_notification: 8.0.0
- user_external: 4.0.0 (installed 4.0.0)
Nextcloud Signing status
No errors have been found
Nextcloud Logs
{"reqId":"EVrtz8Jy0KEsnW4vzKyP","level":2,"time":"2026-07-24T18:30:06+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","scriptName":"/var/www/nextcloud/cron.php","message":"The return value of method DateTimeImmutable::modify() should either be used or intentionally ignored by casting it as (void), as DateTimeImmutable::modify() does not modify the object itself at /var/www/nextcloud/apps/dav/lib/CalDAV/CalDavBackend.php#3437","userAgent":"--","version":"34.0.2.1","occ_command":["/var/www/nextcloud/cron.php"],"data":{"app":"PHP"},"id":"6a64638788c39"}
Additional info
No response
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d
- Merged PRs (30d)
- 725
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nextcloud/server
-
3. to review
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
0. Needs triage 33-feedback bug feature: dashboard feature: files feature: theming needs info
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
.htaccess whitelist missing .json/.ftl → files_pdfviewer locale 404s, PDF viewer stuck in English Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
0. Needs triage 34-feedback bug
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
All issues in nextcloud/server
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
phpstan/phpstan-doctrine#794 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Automattic/static-site-importer#1767 ·