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

Compatibility with PHP 7.3 #124

Closed
wants to merge 11 commits into from
Closed

Compatibility with PHP 7.3 #124

wants to merge 11 commits into from

Conversation

sodabrew
Copy link
Contributor

No description provided.

Per the upgrade notes, zend_fcall_info_cache is considered initialized
if zend_fcall_info_cache.function_handler is set.
@sodabrew
Copy link
Contributor Author

Woo! It compiles! Tests are now failing in exactly the expected manner due to changes in PHP master:

========DIFF========
002+ 82a16182a162a163a164a165a16683c001a16182a162a163a164a165a166c0
002- 82a16182a162a163a164a165a16683c001a16182a162a163a164a165a16682c0020003
012+   array(2) {
012-   &array(2) {
021+     NULL
021-     *RECURSION*
041+   array(3) {
041-   &array(3) {
049+       NULL
049-       *RECURSION*
055+   array(3) {
055-   &array(3) {
063+       NULL
063-       *RECURSION*
========DONE========
FAIL Cyclic array test [tests/026.phpt] 

msgpack_pack.c Outdated
@@ -280,15 +280,15 @@ static inline void msgpack_serialize_array(smart_str *buf, zval *val, HashTable
value_noref = value;
}

if ((Z_TYPE_P(value_noref) == IS_ARRAY && ZEND_HASH_GET_APPLY_COUNT(Z_ARRVAL_P(value_noref)) > 1)) {
if (Z_TYPE_P(value_noref) == IS_ARRAY && Z_IS_RECURSIVE_P(value_noref)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the test failures may be related to this part.
Z_IS_RECURSIVE is mostly equiv. to ZEND_HASH_GET_APPLY_COUNT > 0 (not > 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! What do you recommend to bridge this gap? Is there a different check that will say if a single count is present?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sadly, I have no idea, probably @laruence will know

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting - the in-tree JSON extension is using GC_IS_RECURSIVE instead of Z_IS_RECURSIVE: https://github.com/php/php-src/blob/master/ext/json/json_encoder.c#L143

Copy link
Contributor

Choose a reason for hiding this comment

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

I was able to fix the yaml ext which have the same issue
php/pecl-file_formats-yaml#33

But this require a bit more change... need to find the proper fix.

@sodabrew
Copy link
Contributor Author

I think this is working now for PHP 7.3, but it still fails for PHP master. I'm waiting for travis-ci/travis-ci#9717 to get a PHP 7.3 image on Travis CI.

@sodabrew
Copy link
Contributor Author

I think I understand the crux of the problem. This module has always behaved incorrectly and the tests were configured to ensure incorrect behavior.

Given this recursive scenario:

$a = array(null);
$b = array(&$a);
$a[0] = &$b;

var_dump($a);

In all versions of PHP 7.x the output of var_dump is:

array(1) {
  [0]=>
  &array(1) {
    [0]=>
    &array(1) {
      [0]=>
      *RECURSION*
    }
  }
}

The unit tests pack and unpack the variable to see how it goes through msgpack:

$serialized = msgpack_pack($a);
$unserialized = msgpack_unpack($serialized);
var_dump($unserialized);

The unit tests then expect to see the following output. Note the expectation of iterating the recursion exactly once, whereas PHP itself does not iterate the recursion at all as seen above:

array(1) {
  [0]=>
  array(1) {
    [0]=>
    array(1) {
      [0]=>
      array(1) {
        [0]=>
        array(1) {
          [0]=>
          NULL
        }
      }
    }
  }
}

Therefore I believe the correct fix is to change the unit tests to match the PHP 7.3 required behavior (i.e. no longer being able to check that we've been through the recursion just once, but rather only being able to check before the zero-th pass) and to change the code to operate the same way for PHP 7.0-7.2.

@sodabrew
Copy link
Contributor Author

And there we have it, tests! Anybody around to code review now?

@sodabrew
Copy link
Contributor Author

Hellooooo PHP 7.3.0 is released already. I'm a bit blocked on updating the memcached pecl module, unless I release-note that msgpack is no longer supported.

@andypost
Copy link
Contributor

@sodabrew are you sure that msgpack unsupported?

@vedadkajtaz
Copy link

@andypost it does not compile with 7.3

@inverse
Copy link

inverse commented Dec 12, 2018

Any update on this PR?

rybakit added a commit to tarantool-php/client that referenced this pull request Dec 15, 2018
@rlerdorf
Copy link
Contributor

I have tested this PR and the changes look good. Could we get this merged, please?

@sodabrew
Copy link
Contributor Author

@laruence perhaps you’ve seen this PR since before you did similar work this week? Did I waste my time here?

carlwgeorge pushed a commit to iusrepo/php73-pecl-msgpack that referenced this pull request Jun 11, 2019
@m6w6 m6w6 closed this Dec 18, 2019
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.

7 participants