Skip to content

v0.2.0

Choose a tag to compare

@RezaKargar RezaKargar released this 15 Feb 20:24
· 7 commits to main since this release

What's Changed

Bug Fix: Array/Object Reference Resolution

The igbinary decoder previously discarded TypeArrayRef and TypeObjectRef back-reference IDs, always returning nil. This caused PHP values that share the same underlying zval (via copy-on-write semantics) to decode as nil in Go.

Root cause: When PHP assigns the same array to multiple keys without modification, igbinary serializes the first occurrence as a full array and subsequent occurrences as back-references (TypeArrayRef). The Go decoder was reading but discarding these reference IDs.

Changes

  • Added a compound value reference table (values []any) to the decoder's reader struct
  • Arrays and objects are registered in the table before populating their contents (supports circular references)
  • decodeRef now resolves references by looking up the table index instead of returning nil
  • Added ErrValueRefOutOfRange sentinel error for invalid reference IDs
  • Updated and added comprehensive tests for reference resolution scenarios
  • Bumped Go version to 1.26.0

Impact

This fix affects any PHP data where the same array or object is assigned to multiple locations within a single igbinary-serialized blob. All such cases are now correctly resolved.