Skip to content

[Bug]: Heap check on a recursive object graph is a fatal error on PHP 8.2 and 8.3 #21

Open

Description

@roxblnfk

Describe the bug

On PHP 8.2 and 8.3 a heap check over an entity with a recursive object graph kills the whole test run. HeapIntegrity::equals() compares objects with == inside try { … } catch (\Error), but before PHP 8.4 a recursive comparison is the fatal error Nesting level too deep - recursive dependency?, which no catch can intercept. The process exits with code 255 and every remaining test is lost. On PHP 8.4+ it is a catchable \Error and equals() returns false as intended.

Is this a regression?

No, the comparison has been like this since the heap check was added.

To Reproduce

  1. PHP 8.2 or 8.3.
  2. An ORM test whose heap holds an entity whose original and current state are two distinct instances of a self-referencing graph (e.g. a parent with a child pointing back at it).
  3. The heap check after the test calls HeapIntegrity::equals() on them and the run dies with PHP Fatal error: Nesting level too deep - recursive dependency? in src/ORM/HeapIntegrity.php.

Expected behaviour

The heap check reports the entity as changed (or compares the graph without recursing forever), and the run goes on.

Media prove

Not applicable.

Database

All of them.

Your environment

cycle/testing 1.x, src/ORM/HeapIntegrity.php (equals()), PHP 8.2 and 8.3.

Additional context

Found while killing escaped mutants in #20; the test covering it is skipped below PHP 8.4. A fix could track visited object pairs (SplObjectStorage) and compare properties itself instead of relying on ==.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions