Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix info headers Extend error in dependant libs #304

Merged
merged 2 commits into from
Nov 2, 2018

Conversation

joshcanhelp
Copy link
Contributor

  • Add a check for existing env data before extending.
  • Remove deprecation TODOs for methods used in other libs
  • Added tests for dependent lib usage.
  • Docblocks

Reported in auth0/laravel-auth0#108
Closes #303

@joshcanhelp joshcanhelp added this to the v5-Next milestone Nov 1, 2018
@@ -54,7 +54,9 @@
<exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
</rule>
<rule ref="Generic.Metrics"/>
<rule ref="Generic.NamingConventions"/>
<rule ref="Generic.NamingConventions">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

PHP formatting directive

*
* @var array
*/
protected $data = [];
protected $data = [ 'name' => 'Not set (PHP)', 'version' => 'Not set (PHP)' ];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Default package data to call out if setPackage is not being called. Worth it to look into setting these in a constructor at some point in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

I rather have whoever reads and pulls this data to add defaults in a transformation rather than sending "defaults" when missing or not set on every request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lbalmaceda - Can't do a transformation without a name present. I think this will help to figure out if we have untracked entries and where they came from.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On second thought ... I think you're right. This is jumping the gun on addressing untracked SDKs. I'll pull this out tomorrow, just me know if you have any other feedback.

Copy link
Member

Choose a reason for hiding this comment

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

In PHP, why wouldn't you be able to ask for the PHP version?
http://php.net/manual/en/function.phpversion.php

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cocojoe - This is the SDK version and has to be set explicitly.

'name' => $name,
'version' => $version,
];
$this->setEnvProperty($name, $version);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sure we're using the correct env format here. Deprecated but needs to be refactored in other libs before it can be removed.

'name' => $name,
'version' => $version,
];
$this->setEnvProperty($name, $version);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deprecated but make sure we're capturing the data here if it's being used anywhere else.


$oldData = $headers->get();
if (! empty( $old_headers['env'] ) && is_array( $old_headers['env'] )) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check for the existence of the env key before trying to set it.

*
* @return void
*/
public function testThatSetEnvironmentSetsDataCorrectly()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test for InformationHeaders:: setEnvironment() while it's still being used.

*
* @return void
*/
public function testThatExtendedHeadersBuildCorrectly()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test for dependent lib behavior (AKA: testing what broke)

*
* @var array
*/
protected $data = [];
protected $data = [ 'name' => 'Not set (PHP)', 'version' => 'Not set (PHP)' ];
Copy link
Contributor

Choose a reason for hiding this comment

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

I rather have whoever reads and pulls this data to add defaults in a transformation rather than sending "defaults" when missing or not set on every request.

class InformationHeaders
{

/**
* Default header data to send.
*
* @var array
*/
protected $data = [];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lbalmaceda - Fixed up!

@joshcanhelp joshcanhelp merged commit e42b2c1 into master Nov 2, 2018
@joshcanhelp joshcanhelp deleted the fix-info-headers-error branch November 2, 2018 14:49
@github-actions
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants