Skip to content

Infinite Loop on callHook and whereIn functions causing apache to restart due to stack overflow #265

Open
@charlesaugust44

Description

@charlesaugust44

I'm developing a new API on Lumen and renaming the columns of the legacy database.

I have two tables, Images and Variants, Images has many Variants.

  • Variants is the mapped name of the table usu_t075varest
  • Images is the mapped name of the table usu_t075desest

Mapped this relation as the Lumen docs suggest:

Image.php

public function variants() {
        return $this->hasMany(Variant::class, 'usu_coddes','usu_coddes');
}
  • usu_coddes is the foreign key on Variants table.
  • usu_coddes is the primary key on Images table.

Calling the the route \api\images\SR16105G13 with no authentication:

public function read($id) {
   $image = Image::where('usu_coddes', $id)
                  ->with('variants')
                  ->first();

   if ($image === null)
      return response(null, 404);

   return response()->json($image);
}

The PHP interpreter never goes beyond the with('variants') function, i did some step by step debugging with Zend debugger and saw that in the function callHook on Sofa\Hookable\Builder it calls the callParent function with the first argument "whereIn" so it will call the parent whereIn on Eloquent\Builder but that function doesn't exists there, so PHP reverts the call back to whereIn on Sofa\Hookable\Builder that calls callHook and so on, until call stack is exceeded for Apache and it reboots killing the connection.

I'm not very familiar with Lumen Eloquent structure to make any modification to solve this, anyone could give me a hand or commit the solution?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions