`ControllerMethodReflector` emits "Undefined array key 1" for parenthesised annotations without `=` (e.g. `@SuppressWarnings(PHPMD.X)`)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
lib/private/AppFramework/Utility/ControllerMethodReflector.php の 60 行目から始めて reflect() を調べ、等号のない括弧内のアノテーション値に注目してください。@SuppressWarnings(PHPMD.CyclomaticComplexity) のようなアノテーションで未定義の配列キーがログに記録されなくなっていること、また key=value アノテーションが引き続き正しく保存されることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- PHP
- スター
- 36.9k
- フォーク
- 5.2k
- 平均マージ
- 2日 5時間
- マージ済み PR(30日)
- 735
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud/server のほかの issue
-
SFTP external storage cannot read RSA private key entered in the web form: “Unable to read key”オープン0. Needs triage 35-feedback bug feature: external storage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
nextcloud/server#64702 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
3. to review
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nextcloud/server#64461 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
0. Needs triage 33-feedback bug feature: dashboard feature: files feature: theming needs info
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nextcloud/server#64113 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
0. Needs triage bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
nextcloud/server#64019 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
.htaccess whitelist missing .json/.ftl → files_pdfviewer locale 404s, PDF viewer stuck in Englishオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
nextcloud/server の issue をすべて見る
似ている issue
-
sync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
bug Feature: Kiosk
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
Infrastructure: actions Module: zmscitizenapi Module: zmsentities php Type: Bug unit tests
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
it-at-m/eappointment#3480 ·
メンテナーはふだん 1 日以内に返信
-
HttpClient
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
CI: composer install fails — league/flysystem 1.x blocked by security advisory GHSA-cxf4-7mrp-vvprオープンdevops type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信