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

PHP - Different class property values ​​with and without php extension #18966

Open
s2x opened this issue Oct 23, 2024 · 0 comments · May be fixed by #18982
Open

PHP - Different class property values ​​with and without php extension #18966

s2x opened this issue Oct 23, 2024 · 0 comments · May be fixed by #18982
Labels
untriaged auto added to all issues by default when created.

Comments

@s2x
Copy link

s2x commented Oct 23, 2024

What version of protobuf and what language are you using?
Version: 4.28.3
Language: PHP

What operating system: Linux - Ubuntu 24.04

What did you do?
Steps to reproduce the behavior:
proto:

message TestOptional {
  optional string test = 1;
}

php

$test = new TestOptional();

$refl = new \ReflectionProperty($test, 'test');
var_dump([
    'getter' => $test->getTest(),
    'has' => $test->hasTest(),
    'ref_val' => $refl->getValue($test),
]);

What did you expect to see
without extension:

array(3) {
  ["getter"]=>
  string(0) ""
  ["has"]=>
  bool(false)
  ["ref_val"]=>
  NULL <---- HERE
}

with extension:

array(3) {
  ["getter"]=>
  string(0) ""
  ["has"]=>
  bool(false)
  ["ref_val"]=>
  string(0) "" <---- HERE
}

In most of my code, this behavior has no impact on the code working properly. However, when I use Symfony Validator, which iterates over class properties, the system behaves differently with and without the extension.

Additionally, with the extension enabled we get a segmentation fault when we want to check a non-existent property. For example when we will ask for test1 field:

$refl = new \ReflectionProperty($test, 'test1');

result:

 4298 segmentation fault (core dumped)
@s2x s2x added the untriaged auto added to all issues by default when created. label Oct 23, 2024
@s2x s2x linked a pull request Oct 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged auto added to all issues by default when created.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant