Skip to content

Commit

Permalink
Deprecate methods and classes related to references
Browse files Browse the repository at this point in the history
  • Loading branch information
iamluc committed Jan 21, 2019
1 parent fad1707 commit 8eed12f
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Blackfire PHP-SDK Changelog
===========================

* 1.18.0 (2019-01-21)

* Deprecate methods and classes related to references

* 1.17.6 (2018-12-17)

* Fix PHPUnit bridge
Expand Down
9 changes: 9 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
PHP-SDK UPGRADE
===============

To v1.18.0
----------

* Methods `Blackfire\LoopClient::promoteReferenceSignal`, `Blackfire\LoopClient::attachReference`,
`Blackfire\Profile\Configuration::getReference`, `Blackfire\Profile\Configuration::setReference`,
`Blackfire\Profile\Configuration::isNewReference`, `Blackfire\Profile\Configuration::setAsReference`
are deprecated.
* Class `\Blackfire\Exception\ReferenceNotFoundException` is deprecated.

To v1.16.0
----------

Expand Down
14 changes: 7 additions & 7 deletions src/Blackfire/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Client
{
const MAX_RETRY = 60;
const NO_REFERENCE_ID = '00000000-0000-0000-0000-000000000000';
const VERSION = '1.17.6';
const VERSION = '1.18.0';

private $config;
private $collabTokens;
Expand Down Expand Up @@ -456,7 +456,7 @@ private function doCreateRequest(ProfileConfiguration $config)

$request = new Profile\Request($config, $data);

if ($config->getReference() && $config->isNewReference()) {
if ($config->getReferenceInternal() && $config->isNewReferenceInternal()) {
// promote the profile as being the new reference
$content = json_encode(['request_id' => $request->getUuid(), 'slot_id' => $details['profileSlot']]);
$this->sendHttpRequest($this->config->getEndpoint().'/api/v1/profiles/'.$request->getUuid().'/promote-reference', 'POST', array('content' => $content), array('Content-Type: application/json'));
Expand Down Expand Up @@ -543,26 +543,26 @@ private function getRequestDetails(ProfileConfiguration $config)
$details['collabToken'] = $personalCollabToken['collabToken'];

$id = self::NO_REFERENCE_ID;
if ($config->getReference() || $config->isNewReference()) {
if ($config->getReferenceInternal() || $config->isNewReferenceInternal()) {
foreach ($envDetails['profileSlots'] as $profileSlot) {
if ($config->isNewReference()) {
if ($config->isNewReferenceInternal()) {
if ($profileSlot['empty'] && self::NO_REFERENCE_ID !== $profileSlot['id']) {
$id = $profileSlot['id'];

break;
}
} elseif ($config->getReference() == $profileSlot['number'] || $config->getReference() == $profileSlot['id']) {
} elseif ($config->getReferenceInternal() == $profileSlot['number'] || $config->getReferenceInternal() == $profileSlot['id']) {
$id = $profileSlot['id'];

break;
}
}

if (self::NO_REFERENCE_ID === $id) {
if ($config->isNewReference()) {
if ($config->isNewReferenceInternal()) {
throw new ReferenceNotFoundException('Unable to create a new reference, your reference quota is reached');
} else {
throw new ReferenceNotFoundException(sprintf('Unable to find the "%s" reference.', $config->getReference()));
throw new ReferenceNotFoundException(sprintf('Unable to find the "%s" reference.', $config->getReferenceInternal()));
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/Blackfire/Exception/ReferenceNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

namespace Blackfire\Exception;

@trigger_error('The \Blackfire\Exception\ReferenceNotFoundException class is deprecated since blackfire/php-sdk 1.14 and will be removed in 2.0.', E_USER_DEPRECATED);

This comment has been minimized.

Copy link
@staabm

staabm Jan 22, 2019

1.14 vs. 1.18 in the phpdoc comment below

This comment has been minimized.

Copy link
@iamluc

iamluc Jan 22, 2019

Author Contributor

Thanks! Fixed in master


/**
* @deprecated since 1.18, to be removed in 2.0.
*/
class ReferenceNotFoundException extends RuntimeException
{
}
8 changes: 8 additions & 0 deletions src/Blackfire/LoopClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ public function setSignal($signal)

/**
* @param int $signal A signal that triggers profiling for a reference (like SIGUSR2)
*
* @deprecated since 1.18, to be removed in 2.0.
*/
public function promoteReferenceSignal($signal)
{
@trigger_error('The method "promoteReferenceSignal" is deprecated since blackfire/php-sdk 1.18 and will be removed in 2.0.', E_USER_DEPRECATED);

if (!$this->referenceId) {
throw new LogicException('Cannot set signal to promote the reference without an attached reference (call attachReference() first).');
}
Expand All @@ -85,9 +89,13 @@ public function promoteReferenceSignal($signal)

/**
* @param int $referenceId The reference ID to use (rolling reference)
*
* @deprecated since 1.18, to be removed in 2.0.
*/
public function attachReference($referenceId)
{
@trigger_error('The method "attachReference" is deprecated since blackfire/php-sdk 1.18 and will be removed in 2.0.', E_USER_DEPRECATED);

$this->referenceId = $referenceId;
}

Expand Down
34 changes: 34 additions & 0 deletions src/Blackfire/Profile/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,65 @@ public function setRequestInfo(array $info)
return $this;
}

/**
* @deprecated since 1.18, to be removed in 2.0.
*/
public function getReference()
{
@trigger_error('The method "getReference" is deprecated since blackfire/php-sdk 1.18 and will be removed in 2.0.', E_USER_DEPRECATED);

return $this->reference;
}

/**
* @internal
*/
public function getReferenceInternal()
{
return $this->reference;
}

/**
* @return $this
*
* @deprecated since 1.18, to be removed in 2.0.
*/
public function setReference($reference)
{
@trigger_error('The method "setReference" is deprecated since blackfire/php-sdk 1.18 and will be removed in 2.0.', E_USER_DEPRECATED);

$this->reference = $reference;

return $this;
}

/**
* @deprecated since 1.18, to be removed in 2.0.
*/
public function isNewReference()
{
@trigger_error('The method "isNewReference" is deprecated since blackfire/php-sdk 1.18 and will be removed in 2.0.', E_USER_DEPRECATED);

return $this->isReference;
}

/**
* @internal
*/
public function isNewReferenceInternal()
{
return $this->isReference;
}

/**
* @return $this
*
* @deprecated since 1.18, to be removed in 2.0.
*/
public function setAsReference()
{
@trigger_error('The method "setAsReference" is deprecated since blackfire/php-sdk 1.18 and will be removed in 2.0.', E_USER_DEPRECATED);

$this->isReference = true;

return $this;
Expand Down

0 comments on commit 8eed12f

Please sign in to comment.