Hi,

I've encountered a hard-to-consistently-reproduce issue with HashTable
zvals. I have code that will generate big nested \stdClass structures for
JSON encoding. It does so using classes that have methods that generate
those fields. For example, you could have a class like this:

class Block {
  public function css_classes() {
    return ['x', 'y', 'z'];
  }
}

Other code would translate it into a value that would var_dump() as this:

object(stdClass)#1 (1) {
  ["css_classes"]=>
  array(3) {
    [0]=>
    string(1) "x"
    [1]=>
    string(1) "y"
    [2]=>
    string(1) "z"
  }
}

The template data could include multiple instances of Block. As in, a
\stdClass could be generated with multiple copies of that array content.
That data could get sent to json_encode(), which
uses ZEND_HASH_APPLY_PROTECTION/etc. to avoid recursion. I've seen
situations where that array of strings triggers that recursion check. But
it's not always, and a php-fpm restart can make it go away.

Can anyone think of why this might happen?

Thanks,
Adam

Reply via email to