`ControllerMethodReflector` emits "Undefined array key 1" for parenthesised annotations without `=` (e.g. `@SuppressWarnings(PHPMD.X)`)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
Research direction
Start in lib/private/AppFramework/Utility/ControllerMethodReflector.php at line 60 and inspect reflect(), focusing on parenthesised annotation values without an equals sign. Confirm that annotations such as @SuppressWarnings(PHPMD.CyclomaticComplexity) no longer log an undefined array key, while key=value annotations continue to be stored correctly.
Written by the indexing model from the issue text.
Description
Version: Nextcloud 35.0.1 (same code on master), PHP 8.5
What happens
Every request to a controller method whose docblock contains a PHPMD suppression like
/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
logs a warning:
Undefined array key 1 at lib/private/AppFramework/Utility/ControllerMethodReflector.php#60
On our instance with OpenRegister/Pipelinq (which use such suppressions in 130 controller files) this is ~370 log entries a day.
Why
reflect() treats any @Annotation(...) value as a key=value list:
foreach ($splitArray as $annotationValues) {
[$key, $value] = explode('=', $annotationValues); // no '=' → only one element
PHPMD.CyclomaticComplexity has no =, so index 1 is undefined. As a side effect the inner $key
also shadows the outer foreach key.
Suggested fix
Only split when there is an =, and use a separate variable name:
foreach ($splitArray as $annotationValues) {
if (!str_contains($annotationValues, '=')) {
$this->annotations[$annotation][$annotationValues] = '';
continue;
}
[$paramKey, $paramValue] = explode('=', $annotationValues, 2);
$this->annotations[$annotation][$paramKey] = $paramValue;
}
Workaround we use meanwhile: a space before the parenthesis (@SuppressWarnings (PHPMD.X)) so the value is
stored as a plain string.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 735
Getting set up
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
-
SFTP external storage cannot read RSA private key entered in the web form: “Unable to read key”Open0. Needs triage 35-feedback bug feature: external storage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
nextcloud/server#64702 · 2 comments ·
Maintainers usually reply within 1 day
-
3. to review
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/server#64461 · 1 comment ·
Maintainers usually reply within 1 day
-
0. Needs triage 33-feedback bug feature: dashboard feature: files feature: theming needs info
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/server#64113 · 1 comment ·
Maintainers usually reply within 1 day
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
nextcloud/server#64019 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
.htaccess whitelist missing .json/.ftl → files_pdfviewer locale 404s, PDF viewer stuck in EnglishOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
All issues in nextcloud/server
Similar issues
-
sync-en
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
bug Feature: Kiosk
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Infrastructure: actions Module: zmscitizenapi Module: zmsentities php Type: Bug unit tests
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
it-at-m/eappointment#3480 ·
Maintainers usually reply within 1 day
-
HttpClient
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
CI: composer install fails — league/flysystem 1.x blocked by security advisory GHSA-cxf4-7mrp-vvprOpendevops type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day