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

curl-init.xml: replace 'resource' to 'session' #3623

Merged
merged 6 commits into from
Nov 8, 2024

Conversation

mmalferov
Copy link
Member

I think that in the context of the curl_init() function, it is appropriate to replace the term "resource" with the term "session", since the resource is no longer relevant since PHP 8.0.0, and the session is relevant for both newer versions of PHP and before PHP 8.0.0

I think that in the context of the curl_init() function, it is appropriate to replace the term "resource" with the term "session", since the resource is no longer relevant since PHP 8.0.0, and the session is relevant for both newer versions of PHP and before PHP 8.0.0
Comment on lines 102 to 104
// close cURL resource, and free up system resources
// Close cURL session, and free up system resources
curl_close($ch);
Copy link
Member

Choose a reason for hiding this comment

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

The new comment doesn't seem to be right. The old comment would at least be correct prior to PHP 8.0.0. Not sure how to improve the comment; see also the related #3622 (comment).

Copy link
Member Author

Choose a reason for hiding this comment

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

I seem to be confused about the times before PHP 8.0.0 and after)

I don't understand why we can't change the current comment:

close cURL resource, and free up system resources

with a new one:

Close cURL session, and free up system resources

for the call curl_close($ch).

I'll leave it here so I don't forget what the fuctions are doing:

  • curl_init — Initialize a cURL session
  • curl_close — Close a cURL session

— Prior to PHP 8.0.0, the part "close the cURL resource" was relevant, but since version 8.0.0 it has not been, since resource was replaced by CurlHandle class.
— The phrase "close the cURL session" is relevant for both version.

===

I think it's better to move on to the second part of the sentence after we've dealt with the first one. Because the wording

and free up system resources

worked only prior to PHP 8.0.0 and lost its relevance as of PHP 8.0.0.

And my main question in #3622 was how to replace the outdated curl_close call as of PHP 8.0.0?

I remember about the refcounter and the garbage collector, which destroys symbols that have no references left. That's not the main question. The main question is that once the curl_close call was specified in the examples, it was probably necessary for some reason. Calling curl_close no longer has an effect, but remains in the example. The documentation mentions the lack of effect as of PHP 8.0, but does not say what to do for those who, as of PHP 8.0.0, for some reason, still need to free up system resources occupied by easy handles (e.g. in multi handle contained 5000 easy handles) manually (e.g. after reading of easy handle data).

But help me first understand the first part of the sentence: why we can't replace the word resource with the word session?

Copy link
Member

Choose a reason for hiding this comment

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

You are right that this change would already be an improvement, and as such might be good as is. But maybe we can even do better:

// Close cURL session, and free up system resources (prior to PHP 8.0.0)

Copy link
Member

Choose a reason for hiding this comment

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

You are right that this change would already be an improvement, and as such might be good as is. But maybe we can even do better:

// Close cURL session, and free up system resources (prior to PHP 8.0.0)

That would still be misleading. If I understand correctly, this function does nothing as of PHP 8.0. It doesn't close a session and it doesn't free up resources. Prior to PHP 8.0, it closed the resource.

I propose a simpler solution, just remove curl_close and its comment from this example. It's useless anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, maybe we should just remove it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have removed every mention of curl_close from the page in f33d219 commit. At the same time, I removed the trailing whitespace characters and added the echo construction to curl_exec($ch) so that the output would actually be passed to the browser

@kamil-tekiela
Copy link
Member

Doesn't it still use a resource under the hood? I think cUrl resource still makes sense.

@mmalferov
Copy link
Member Author

I wish I could agree with you, but I can't. cUrl resource still makes sense... for what? I think, it make sense only prior to PHP 8.0.0.

In the meantime, I'm trying to realize a) why the curl_close() calls were specified in the examples (probably to free up system resources manually when the need for a easy handle disappeared) and if these calls were actualy needed prior to PHP 8.0.0, then b) what exactly should replace them as of PHP 8.0.0, taking into account the fact that the curl_close() call no longer has an effect?..

mmalferov and others added 2 commits October 29, 2024 14:59
I have removed every mention of `curl_close` from the page. At the same time, I removed the trailing whitespace characters and added the `echo` construction to `curl_exec($ch)` so that the output would actually be passed to the browser
// grab URL and pass it to the browser
curl_exec($ch);
// Grab URL and pass it to the browser
echo curl_exec($ch);
Copy link
Member

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but I thought that curl_exec() already does echo internally. You'd need to explicitly disable it with CURLOPT_RETURNTRANSFER

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, curl_exec display result without echo, if CURLOPT_RETURNTRANSFER not provided; I was just playing with cURL and used this option))

I looked at the curl_exec page and found no mention of the function having an internal output. I think we should go back to curl_exec a little later and add one sentence about it.

Yes, I almost forgot. Maybe it makes sense to add a mention of easy to the wording for a simple descriptor? For example, like this:

Initializes a new session and returns a cURL easy handle.

Copy link
Member

Choose a reason for hiding this comment

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

No, just leave it as I suggested and remove the rest of the sentence.

Copy link
Member

@kamil-tekiela kamil-tekiela left a comment

Choose a reason for hiding this comment

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

Thanks! Look ok now. @cmb69 What do you think?

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

While I wouldn't mention the browser, this is okay for me.

@kamil-tekiela kamil-tekiela merged commit 61f6578 into php:master Nov 8, 2024
2 checks passed
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.

4 participants