diff --git a/Player/Extension/BlackfireExtension.php b/Player/Extension/BlackfireExtension.php index 603f04df..17461214 100644 --- a/Player/Extension/BlackfireExtension.php +++ b/Player/Extension/BlackfireExtension.php @@ -212,6 +212,9 @@ public function afterStep(AbstractStep $step, StepContext $stepContext, Scenario $parentStep = $step->getInitiator(); $profile = $this->blackfire->getProfile($uuid); + // Initialize profile data by calling getUrl() + $profile->getUrl(); + $parentStep->setBlackfireProfileUuid($uuid); $this->assertProfile($parentStep, $profile); } diff --git a/Player/Extension/ProcessedException.php b/Player/Extension/ProcessedException.php new file mode 100644 index 00000000..dc80c3b5 --- /dev/null +++ b/Player/Extension/ProcessedException.php @@ -0,0 +1,16 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Blackfire\Player\Extension; + +class ProcessedException extends \RuntimeException +{ +} diff --git a/Player/PlayerNext.php b/Player/PlayerNext.php index 76bbe201..116fb3ad 100644 --- a/Player/PlayerNext.php +++ b/Player/PlayerNext.php @@ -14,6 +14,7 @@ use Blackfire\Player\Enum\BuildStatus; use Blackfire\Player\Extension\ExceptionExtensionInterface; use Blackfire\Player\Extension\NextStepExtensionInterface; +use Blackfire\Player\Extension\ProcessedException; use Blackfire\Player\Extension\ScenarioExtensionInterface; use Blackfire\Player\Extension\ScenarioSetExtensionInterface; use Blackfire\Player\Extension\StepExtensionInterface; @@ -122,10 +123,8 @@ private function handleScenario(int|string $index, Scenario $scenario, ScenarioS ); } catch (\Throwable $e) { $exception = $e; - foreach ($this->getSortedExtensions() as $extension) { - if ($extension instanceof ExceptionExtensionInterface) { - $extension->failStep($this->currentStep, $e); - } + if ($e instanceof ProcessedException) { + $exception = $e->getPrevious(); } } @@ -211,6 +210,16 @@ private function handleStep(ConfigurableStep $step, StepContext $stepContext, Sc } } } + } catch (ProcessedException $exception) { + throw $exception; + } catch (\Throwable $exception) { + foreach ($this->getSortedExtensions() as $extension) { + if ($extension instanceof ExceptionExtensionInterface) { + $extension->failStep($this->currentStep, $exception); + } + } + + throw new ProcessedException($exception->getMessage(), $exception->getCode(), $exception); } finally { $step->setStatus(BuildStatus::DONE); diff --git a/Player/Tests/Adapter/StubbedSdkAdapter.php b/Player/Tests/Adapter/StubbedSdkAdapter.php index fb7644ba..d20749ab 100644 --- a/Player/Tests/Adapter/StubbedSdkAdapter.php +++ b/Player/Tests/Adapter/StubbedSdkAdapter.php @@ -60,7 +60,16 @@ public function getProfile(string $uuid): Profile return ($this->profileFactory)($uuid); } - return new Profile(fn () => ['report' => ['state' => 'successful']], $uuid); + return new Profile(fn () => [ + 'report' => [ + 'state' => 'successful', + ], + '_links' => [ + 'graph_url' => [ + 'href' => \sprintf('https://app.blackfire.io/profiles/%s/graph', $uuid), + ], + ], + ], $uuid); } public function startBuild(string|null $env = null, array $options = []): Build diff --git a/Player/Tests/fixtures-run-with-env/profile-assertion-failure/stubbedSdkAdapter.php b/Player/Tests/fixtures-run-with-env/profile-assertion-failure/stubbedSdkAdapter.php index 102aa621..be0423f7 100644 --- a/Player/Tests/fixtures-run-with-env/profile-assertion-failure/stubbedSdkAdapter.php +++ b/Player/Tests/fixtures-run-with-env/profile-assertion-failure/stubbedSdkAdapter.php @@ -26,6 +26,11 @@ ], ], ], + '_links' => [ + 'graph_url' => [ + 'href' => sprintf('https://app.blackfire.io/profiles/%s/graph', $uuid), + ], + ], ], $uuid); } ); diff --git a/composer.json b/composer.json index a4fc4185..74350f67 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "ext-filter": "*", "ext-intl": "*", "ext-mbstring": "*", - "blackfire/php-sdk": "^2.1 ", + "blackfire/php-sdk": "^2.5", "fakerphp/faker": "^1.10", "maltyxx/images-generator": "^1.0", "mtdowling/jmespath.php": "^2.2", diff --git a/composer.lock b/composer.lock index 33978bdf..dcf86733 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "25c8be0e135f0bd99b02a125b0d4d9d6", + "content-hash": "7530115eb6d3bf5fa0c0af18fdee633c", "packages": [ { "name": "blackfire/php-sdk", - "version": "v2.5.5", + "version": "v2.5.6", "source": { "type": "git", "url": "https://github.com/blackfireio/php-sdk.git", - "reference": "3a7d6d01d4a237f33304ba0aea38b065e06d908e" + "reference": "838070d422321c3de4b01254a28ccd2dc19ab45e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/blackfireio/php-sdk/zipball/3a7d6d01d4a237f33304ba0aea38b065e06d908e", - "reference": "3a7d6d01d4a237f33304ba0aea38b065e06d908e", + "url": "https://api.github.com/repos/blackfireio/php-sdk/zipball/838070d422321c3de4b01254a28ccd2dc19ab45e", + "reference": "838070d422321c3de4b01254a28ccd2dc19ab45e", "shasum": "" }, "require": { @@ -78,9 +78,9 @@ ], "support": { "issues": "https://github.com/blackfireio/php-sdk/issues", - "source": "https://github.com/blackfireio/php-sdk/tree/v2.5.5" + "source": "https://github.com/blackfireio/php-sdk/tree/v2.5.6" }, - "time": "2024-12-23T09:51:54+00:00" + "time": "2025-01-10T13:15:06+00:00" }, { "name": "composer/ca-bundle",