Skip to content

Fix the bug where clone curl does not copy POST fields. #16556

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

matyhtf
Copy link
Contributor

@matyhtf matyhtf commented Oct 23, 2024

No description provided.

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.

Thank you for the PR!

I think this also affects older PHP branches; should likely target PHP-8.2.

postfields = &clone_ch->postfields;
postfields = &ch->postfields;
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the actual problem that we don't clone the ->postfields in the first place? I.e. ZVAL_COPY(&clone_ch->postfields, &ch->postfields).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code should behave consistently with PHP_FUNCTION(curl_copy_handle), with the only difference being the return value. This PR primarily aims to fix this bug, and a subsequent PR for code optimization can be submitted to implement a reusable function.

postfields = &ch->postfields;

Copy link
Member

Choose a reason for hiding this comment

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

If you clone an object, you should clone all its properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have modified the code to use ZVAL_COPY for postfields and updated PHP_FUNCTION(curl_copy_handle) to ensure consistency with the clone operation.

@matyhtf matyhtf force-pushed the fix-curl-handle-clone branch from 5d10a33 to a0dd445 Compare November 26, 2024 08:44
@matyhtf
Copy link
Contributor Author

matyhtf commented Nov 26, 2024

Updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants