Skip to content

Conversation

@huangdijia
Copy link
Contributor

@huangdijia huangdijia commented Dec 23, 2025

Summary

  • Fix inverted condition for singleton key generation with arguments
  • The ! array_key_exists(0, $arguments) was incorrectly negating the check

Test plan

  • Verified the condition logic now correctly appends #{argument} when getInstance is called with an argument
  • Code follows existing patterns in the codebase

🤖 Generated with Claude Code

Summary by CodeRabbit

发布说明

  • Bug 修复
    • 修正单例缓存键的构建逻辑,确保根据正确的条件判断缓存实例的检索和创建方式。

✏️ Tip: You can customize this high-level summary in your review settings.

The condition for appending argument-based suffix to the singleton key
was inverted. Changed from `! array_key_exists(0, $arguments)` to
`array_key_exists(0, $arguments)` to properly generate unique keys
when getInstance is called with an argument.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings December 23, 2025 01:22
@coderabbitai
Copy link

coderabbitai bot commented Dec 23, 2025

Caution

Review failed

The pull request is closed.

概述

SingletonAspect.php 中反转了第一个参数的存在性检查条件,改变了缓存键的构建逻辑:从"仅当第一个参数不存在时才追加"改为"仅当第一个参数存在时才追加",从而影响单例绑定类/枚举的缓存实例检索和创建行为。

更改内容

内聚组 / 文件 更改摘要
单例缓存键逻辑反转
src/sentry/src/Aspect/SingletonAspect.php
反转第一个参数的存在性检查条件(isset($arguments[0])),影响缓存键的构建逻辑和单例实例的检索/创建行为

预估代码审查工作量

🎯 2 (Simple) | ⏱️ ~8 分钟

相关的可能 PR

诗歌

🐰 缓存键的逻辑反转妙,
何时追加有讲究,
存在即加,逻辑更清晰,
单例实例各归其所!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/sentry-singleton-aspect-logic

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 14377b0 and 7de246d.

📒 Files selected for processing (1)
  • src/sentry/src/Aspect/SingletonAspect.php

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PHPStan (2.1.33)

At least one path must be specified to analyse.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@huangdijia huangdijia merged commit 7622537 into main Dec 23, 2025
9 of 10 checks passed
@huangdijia huangdijia deleted the fix/sentry-singleton-aspect-logic branch December 23, 2025 01:23
huangdijia added a commit that referenced this pull request Dec 23, 2025
#1051)

The condition for appending argument-based suffix to the singleton key
was inverted. Changed from `! array_key_exists(0, $arguments)` to
`array_key_exists(0, $arguments)` to properly generate unique keys
when getInstance is called with an argument.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
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