Skip to content

THRIFT-796: Do not change field types in thrift_protocol_write_binary - #4160

Open
slachiewicz wants to merge 1 commit into
apache:masterfrom
slachiewicz:THRIFT-796
Open

slachiewicz wants to merge 1 commit into
apache:masterfrom
slachiewicz:THRIFT-796

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

Jira: THRIFT-796

The C extension's thrift_protocol_write_binary ran convert_to_long/string/double/array directly on the zval of the caller's struct property, so serializing a struct changed the field's PHP type: an i32 field holding "100" came back as 100, and the reverse for strings. The conversion now runs on a copy that is released on scope exit; the bytes on the wire are unchanged.

The PHPUnit test skips itself when the extension is not loaded, and the lib-php job runs PHPUnit without it, so CI covers this only once #4122 (THRIFT-6515) loads the extension in that job.

Verified: with the extension built from this branch, tests/argument_not_mutated.phpt passes and TBinaryProtocolAcceleratedTest passes 7 of 7 (PHP_INI_SCAN_DIR loading the extension, since phpunit.xml uses process isolation); built from master, the new test fails with 100 !== "100". phpcs clean.

  • Did you create an Apache Jira ticket?
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-796: describe my issue"?
  • Did you squash your changes to a single commit?
  • Did you do your best to avoid breaking changes? Same wire output; only the caller's object is no longer modified.

Client: php

binary_serialize() ran convert_to_long/string/double/array directly on the
zval of the caller's property, so serializing a struct turned an int field
holding "100" into 100 (and the reverse). The conversion now runs on a copy
that is released on scope exit; the wire output is the same. Covered by a
phpt in the extension and a PHPUnit test in TBinaryProtocolAcceleratedTest.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@mergeable mergeable Bot added the php label Nov 8, 2026
@slachiewicz
slachiewicz marked this pull request as ready for review November 8, 2026 20:16
@slachiewicz
slachiewicz requested a review from sveneld as a code owner November 8, 2026 20:16
Copilot AI balanced review requested due to automatic review settings November 8, 2026 20:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants