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: Optimize the usage of option 'baseURI' for CURLRequest #9273

Closed
wants to merge 1 commit into from

Conversation

warmbook
Copy link

@warmbook warmbook commented Nov 13, 2024

#9265
Description
Use option 'baseURI' first in Config\Services->curlrequest.
Use the property 'uri' of OutgoingRequest as default baseURI instead of the property 'baseURI' of CURLRequest.
Remove the property 'baseURI' of CURLRequest.
Nolonger parse 'baseURI' in 'parseOptions' method.
If 'baseURI' exists in 'request' method's options, create a new URI instance with it. Otherwise, use the property 'uri' of OutgoingRequest.
Use the param '$uri' passed in rather than the property 'baseURI' of CURLRequest in 'prepareURL' method.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@@ -208,10 +209,12 @@ public static function curlrequest(array $options = [], ?ResponseInterface $resp

$config ??= config(App::class);
$response ??= new Response($config);
$uri = new URI($options['baseURI'] ?? ($options['base_uri'] ?? null));
Copy link
Member

Choose a reason for hiding this comment

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

parentheses should not needed:

Suggested change
$uri = new URI($options['baseURI'] ?? ($options['base_uri'] ?? null));
$uri = new URI($options['baseURI'] ?? $options['base_uri'] ?? null);

*
* @var URI
*/
protected $baseURI;
Copy link
Member

Choose a reason for hiding this comment

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

bc break.

Copy link
Author

Choose a reason for hiding this comment

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

Excuse me, this is my first time to submit pull request. What's meaning 'bc break'? And what should I do next?

Copy link
Member

Choose a reason for hiding this comment

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

backward compatibility break, remove protected property is not allowed on fix pr.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! Maybe I should submit to next version.

*/
protected function prepareURL(string $url): string
protected function prepareURL(string $url, URI $uri): string
Copy link
Member

Choose a reason for hiding this comment

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

bc break as well.

@warmbook warmbook closed this Nov 13, 2024
@michalsn
Copy link
Member

@warmbook The only thing that needs to be changed is one line:

- $uri = new URI($options['base_uri'] ?? null);
+ $uri = new URI($options['baseURI'] ?? null);

It was a bug - in this particular case, there is no need to worry about deprecating anything. Just add an entry to the changelog with a description that it has been fixed.

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.

3 participants