Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sentry/src/Tracing/Aspect/CoroutineAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint)
$transaction = SentrySdk::getCurrentHub()->getTransaction();

// If there's no active transaction, skip tracing.
if (! $transaction || ! $transaction->getSampled()) {
if (! $transaction?->getSampled()) {
return $proceedingJoinPoint->process();
}

Expand Down
10 changes: 5 additions & 5 deletions src/sentry/src/Tracing/Listener/EventHandleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ protected function handleCommandFinished(CommandEvent\AfterExecute $event): void
{
$transaction = SentrySdk::getCurrentHub()->getTransaction();

if (! $transaction || ! $transaction->getSampled()) {
if (! $transaction?->getSampled()) {
return;
}
Comment on lines +407 to 409
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

统一使用 $transaction?->getSampled() 判空+采样检查,保持原有早退行为。

  • 改动保持功能不变,避免在 $transaction 为空时调用方法的风险,符合代码库现有风格(PSR-12 间距也保持一致)。
  • 请确认组件(及 monorepo 根)composer 最低 PHP 版本约束≥8.0,以确保 nullsafe 语法在分发环境无兼容风险。

运行以下脚本快速检查仓库中各 composer.json 的 PHP 版本约束:

Also applies to: 520-522, 588-590, 656-658, 707-709


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "Composer PHP 版本约束扫描:"
fd -a composer.json | while read -r f; do
  req=$(jq -r '.require.php // empty' "$f" 2>/dev/null || true)
  if [ -z "$req" ]; then
    req=$(rg -nP '"php"\s*:\s*"[^"]+"' "$f" -N -S -o | sed -E 's/.*"php"\s*:\s*"([^"]+)".*/\1/' || true)
  fi
  printf "%s => %s\n" "$f" "${req:-<未声明>}"
done

Length of output: 3161


在 src/sentry/composer.json 中添加 PHP 最低版本约束

  • 根据 monorepo 根 composer.json (>=8.1),请在 src/sentry/composer.jsonrequire 段中增加 "php": ">=8.1" 以确保 nullsafe 操作符(PHP 8.0+)在分发环境可用。
🤖 Prompt for AI Agents
In src/sentry/src/Tracing/Listener/EventHandleListener.php around lines 407 to
409, the code uses the nullsafe operator but src/sentry/composer.json lacks a
PHP version constraint; open src/sentry/composer.json and add or update the
"require" section to include "php": ">=8.1" (matching the monorepo root), then
run composer validate and composer update (or composer install) to regenerate
lock files so the package declares PHP >=8.1.


Expand Down Expand Up @@ -517,7 +517,7 @@ protected function handleCrontabTaskFinished(CrontabEvent\FailToExecute|CrontabE
{
$transaction = SentrySdk::getCurrentHub()->getTransaction();

if (! $transaction || ! $transaction->getSampled()) {
if (! $transaction?->getSampled()) {
return;
}

Expand Down Expand Up @@ -585,7 +585,7 @@ protected function handleAmqpMessageProcessed(AmqpEvent\AfterConsume|AmqpEvent\F
{
$transaction = SentrySdk::getCurrentHub()->getTransaction();

if (! $transaction || ! $transaction->getSampled()) {
if (! $transaction?->getSampled()) {
return;
}

Expand Down Expand Up @@ -653,7 +653,7 @@ protected function handleKafkaMessageProcessed(KafkaEvent\AfterConsume|KafkaEven
{
$transaction = SentrySdk::getCurrentHub()->getTransaction();

if (! $transaction || ! $transaction->getSampled()) {
if (! $transaction?->getSampled()) {
return;
}

Expand Down Expand Up @@ -704,7 +704,7 @@ protected function handleAsyncQueueJobProcessed(AsyncQueueEvent\AfterHandle|Asyn
{
$transaction = SentrySdk::getCurrentHub()->getTransaction();

if (! $transaction || ! $transaction->getSampled()) {
if (! $transaction?->getSampled()) {
return;
}

Expand Down