Skip to content

fix: handle deprecated code related to comments app#41656

Merged
DeepDiver1975 merged 1 commit into
masterfrom
fix/deprecated-comments-app
Jun 26, 2026
Merged

fix: handle deprecated code related to comments app#41656
DeepDiver1975 merged 1 commit into
masterfrom
fix/deprecated-comments-app

Conversation

@phil-davis

Copy link
Copy Markdown
Contributor

Code paths that caused deprecation warnings in PHP 8 have been corrected.

When running a comments app API acceptance test scenario locally, I got the following output:

$ make test-acceptance-api BEHAT_FEATURE=tests/acceptance/features/apiComments/comments.feature:9

  Scenario: Getting info of comments using files endpoint                                                 # /home/phil/git/owncloud/core/tests/acceptance/features/apiComments/comments.feature:9
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40580 Accepted
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40580 [201]: PUT /remote.php/dav/files/Alice/myFileToComment.txt
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40580 Closing
    Given user "Alice" has uploaded file "filesForUpload/textfile.txt" to "/myFileToComment.txt"          # FeatureContext::userHasUploadedAFileTo()
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40588 Accepted
[Fri Jun 26 21:11:37 2026] strtolower(): Passing null to parameter #1 ($string) of type string is deprecated at /home/phil/git/owncloud/core/apps/dav/lib/Server.php#243
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40588 [207]: PROPFIND /remote.php/dav/files/Alice/myFileToComment.txt
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40588 Closing
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40594 Accepted
[Fri Jun 26 21:11:37 2026] DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated at /home/phil/git/owncloud/core/apps/comments/lib/Dav/EntityCollection.php#174
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40594 [201]: POST /remote.php/dav/comments/files/2147484663
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40594 Closing
    And user "Alice" has commented with content "My first comment" on file "/myFileToComment.txt"         # CommentsContext::userHasCommentedWithContentOnEntry()
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40610 Accepted
[Fri Jun 26 21:11:37 2026] strtolower(): Passing null to parameter #1 ($string) of type string is deprecated at /home/phil/git/owncloud/core/apps/dav/lib/Server.php#243
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40610 [207]: PROPFIND /remote.php/dav/files/Alice/myFileToComment.txt
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40610 Closing
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40612 Accepted
[Fri Jun 26 21:11:37 2026] Undefined array key "{http://owncloud.org/ns}actorDisplayName" at /home/phil/git/owncloud/core/apps/comments/lib/Dav/CommentNode.php#231
[Fri Jun 26 21:11:37 2026] method_exists(): Passing null to parameter #2 ($method) of type string is deprecated at /home/phil/git/owncloud/core/apps/comments/lib/Dav/CommentNode.php#232
[Fri Jun 26 21:11:37 2026] Undefined array key "{http://owncloud.org/ns}isUnread" at /home/phil/git/owncloud/core/apps/comments/lib/Dav/CommentNode.php#231
[Fri Jun 26 21:11:37 2026] method_exists(): Passing null to parameter #2 ($method) of type string is deprecated at /home/phil/git/owncloud/core/apps/comments/lib/Dav/CommentNode.php#232
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40612 [207]: REPORT /remote.php/dav/comments/files/2147484663
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40612 Closing
    And user "Alice" should have the following comments on file "/myFileToComment.txt"                    # CommentsContext::checkComments()
      | user  | comment          |
      | Alice | My first comment |
[Fri Jun 26 21:11:37 2026] 127.0.0.1:40614 Accepted
[Fri Jun 26 21:11:38 2026] 127.0.0.1:40614 [207]: PROPFIND /remote.php/dav/files/Alice/myFileToComment.txt
[Fri Jun 26 21:11:38 2026] 127.0.0.1:40614 Closing
    When user "Alice" gets the following properties of folder "/myFileToComment.txt" using the WebDAV API # WebDavPropertiesContext::userGetsPropertiesOfFolder()
      | propertyName       |
      | oc:comments-href   |
      | oc:comments-count  |
      | oc:comments-unread |
    Then the HTTP status code should be "201"                                                             # FeatureContext::thenTheHTTPStatusCodeShouldBe()
    And the single response should contain a property "oc:comments-count" with value "1"                  # WebDavPropertiesContext::theSingleResponseShouldContainAPropertyWithValue()
    And the single response should contain a property "oc:comments-unread" with value "0"                 # WebDavPropertiesContext::theSingleResponseShouldContainAPropertyWithValue()
    And the single response should contain a property "oc:comments-href" with value "%a_comment_url%"     # WebDavPropertiesContext::theSingleResponseShouldContainAPropertyWithValue()

There are 3 different deprecation warnings emitted. This PR fixes them:

strtolower(): Passing null to parameter #1 ($string) of type string is deprecated at /home/phil/git/owncloud/core/apps/dav/lib/Server.php#243
DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated at /home/phil/git/owncloud/core/apps/comments/lib/Dav/EntityCollection.php#174
method_exists(): Passing null to parameter #2 ($method) of type string is deprecated at /home/phil/git/owncloud/core/apps/comments/lib/Dav/CommentNode.php#232

Code paths that caused deprecation warnings in PHP 8 have been corrected.

@DeepDiver1975 DeepDiver1975 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed as maintainer. LGTM — clean, minimal, behavior-preserving null-safety fixes for the three PHP 8 deprecation warnings surfaced by the apiComments acceptance scenario:

  • CommentNode::getProperties()$this->properties[$property] ?? null plus a null guard avoids method_exists(null, …) when a client requests an unmapped property; unknown props are skipped exactly as before, and this also silences the related 'Undefined array key' notice.
  • EntityCollection::setReadMarker()new \DateTime($value ?? 'now') preserves the prior new \DateTime(null) semantics (null was always interpreted as 'now').
  • Server.php PROPFIND handler — strtolower((string) …) maps a missing Depth header (null) to '', which never matched 'infinity' before either, so behavior is unchanged.

All three are equivalent to the pre-PHP-8 behavior with no functional change. Changelog fragment changelog/unreleased/41656 is present and follows TEMPLATE (Bugfix: …, past-tense body, primary PR ID). CI is green including the PHP Unit matrix and the apiComments acceptance suite. Approving.

@DeepDiver1975 DeepDiver1975 merged commit fb96ca6 into master Jun 26, 2026
26 checks passed
@DeepDiver1975 DeepDiver1975 deleted the fix/deprecated-comments-app branch June 26, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants