Skip to content

fix: guard against null keys/aliases to fix PHP 8.4 deprecation warnings#60752

Draft
miaulalala wants to merge 1 commit into
masterfrom
fix/noid/php84-deprecations-lib
Draft

fix: guard against null keys/aliases to fix PHP 8.4 deprecation warnings#60752
miaulalala wants to merge 1 commit into
masterfrom
fix/noid/php84-deprecations-lib

Conversation

@miaulalala
Copy link
Copy Markdown
Contributor

Summary

Fixes three PHP 8.4 deprecation warnings that surface as CI noise and will become failures on PHP 9:

  • CappedMemoryCache: get(), hasKey(), and remove() used null as an array offset when a caller passed a null key (e.g. AccountManager::getAccount() with a mock user whose getUID() returns null). Guard each method with an early null return.
  • QueryBuilder::quoteAlias(): returned null when given a null alias, which then passed through to DBAL's join methods and triggered array_key_exists(null, ...) deprecations. Return '' instead — DBAL treats an empty alias the same as null (no alias in the generated SQL). Updated QueryBuilderTest join expectations accordingly ('joinAlias' => null'joinAlias' => '').
  • user_ldap/Access: $sndAttribute is null when ldapUserDisplayName2 is not configured (group path sets it to null explicitly), but was used as array offset inside the $isUsers branch without a null check.

Test plan

  • Run NOCOVERAGE=1 ./autotest.sh sqlite tests/lib/Accounts/AccountManagerTest.php
  • Run NOCOVERAGE=1 ./autotest.sh sqlite tests/lib/DB/QueryBuilder/QueryBuilderTest.php
  • Confirm the three deprecations no longer appear in CI output

🤖 Generated with Claude Code

@miaulalala miaulalala self-assigned this May 26, 2026
@miaulalala miaulalala force-pushed the fix/noid/php84-deprecations-lib branch 3 times, most recently from edcebd1 to 1bb5354 Compare May 27, 2026 08:07
@miaulalala miaulalala added this to the Nextcloud 35 milestone May 27, 2026
- CappedMemoryCache: return early from get/hasKey/remove when key is null
- QueryBuilder: coerce null alias to '' in join methods only, so DBAL does
  not receive null as an array key; quoteAlias() itself is unchanged so
  from() keeps its null-alias behaviour
- user_ldap Access: guard null sndAttribute before using as array offset

Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@miaulalala miaulalala force-pushed the fix/noid/php84-deprecations-lib branch from 1bb5354 to 5194c38 Compare May 27, 2026 09:19
@miaulalala
Copy link
Copy Markdown
Contributor Author

/backport to stable34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant