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

[Bug]: Throw error in GET list have parameter include is categories or menus #66

Closed
BaoNguyenSE opened this issue Jan 18, 2022 · 22 comments

Comments

@BaoNguyenSE
Copy link

What happened?

version use: v1.3.2
image
any api index have param include relationship one to many
ex: categories, menus,...

What did you expect to happen?

this return list relationship

Version

3.1.x

What browser are you seeing the problem on?

No response

Relevant log output

{
    "message": "Too few arguments to function Igniter\\Flame\\Database\\Pivot::__construct(), 0 passed in /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 2099 and at least 3 expected",
    "status_code": 500,
    "debug": {
        "line": 46,
        "file": "/var/www/html/vendor/tastyigniter/flame/src/Database/Pivot.php",
        "class": "ArgumentCountError",
        "trace": [
            "#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(2099): Igniter\\Flame\\Database\\Pivot->__construct()",
            "#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(2066): Illuminate\\Database\\Eloquent\\Model::getAttributeMarkedMutatorMethods()",
            "#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(2051): Illuminate\\Database\\Eloquent\\Model::cacheMutatedAttributes()",
            "#3 /var/www/html/vendor/tastyigniter/flame/src/Database/Concerns/HasAttributes.php(78): Illuminate\\Database\\Eloquent\\Model->getMutatedAttributes()",
            "#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1485): Igniter\\Flame\\Database\\Model->attributesToArray()",
            "#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php(351): Illuminate\\Database\\Eloquent\\Model->toArray()",
            "#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1485): Illuminate\\Database\\Eloquent\\Model->relationsToArray()",
            "#7 /var/www/html/extensions/igniter/api/apiresources/transformers/CategoryTransformer.php(18): Illuminate\\Database\\Eloquent\\Model->toArray()",
            "#8 /var/www/html/extensions/igniter/api/vendor/league/fractal/src/Scope.php(419): Igniter\\Api\\ApiResources\\Transformers\\CategoryTransformer->transform()",
            "#9 /var/www/html/extensions/igniter/api/vendor/league/fractal/src/Scope.php(361): League\\Fractal\\Scope->fireTransformer()",
            "#10 /var/www/html/extensions/igniter/api/vendor/league/fractal/src/Scope.php(235): League\\Fractal\\Scope->executeResourceTransformers()",
            "#11 /var/www/html/extensions/igniter/api/vendor/league/fractal/src/TransformerAbstract.php(162): League\\Fractal\\Scope->toArray()",
            "#12 /var/www/html/extensions/igniter/api/vendor/league/fractal/src/TransformerAbstract.php(128): League\\Fractal\\TransformerAbstract->includeResourceIfAvailable()",
            "#13 /var/www/html/extensions/igniter/api/vendor/league/fractal/src/Scope.php(447): League\\Fractal\\TransformerAbstract->processIncludedResources()",
            "#14 /var/www/html/extensions/igniter/api/vendor/league/fractal/src/Scope.php(423): League\\Fractal\\Scope->fireIncludedTransformers()",
            "#15 /var/www/html/extensions/igniter/api/vendor/league/fractal/src/Scope.php(361): League\\Fractal\\Scope->fireTransformer()",
            "#16 /var/www/html/extensions/igniter/api/vendor/league/fractal/src/Scope.php(235): League\\Fractal\\Scope->executeResourceTransformers()",
            "#17 /var/www/html/extensions/igniter/api/classes/FractalAdapter.php(51): League\\Fractal\\Scope->toArray()",
            "#18 /var/www/html/extensions/igniter/api/vendor/dingo/api/src/Transformer/Factory.php(77): Igniter\\Api\\Classes\\FractalAdapter->transform()",
            "#19 /var/www/html/extensions/igniter/api/vendor/dingo/api/src/Http/Response.php(136): Dingo\\Api\\Transformer\\Factory->transform()",
            "#20 /var/www/html/extensions/igniter/api/vendor/dingo/api/src/Routing/Router.php(560): Dingo\\Api\\Http\\Response->morph()",
            "#21 /var/www/html/extensions/igniter/api/vendor/dingo/api/src/Routing/Router.php(529): Dingo\\Api\\Routing\\Router->prepareResponse()",
            "#22 /var/www/html/extensions/igniter/api/vendor/dingo/api/src/Http/Middleware/Request.php(126): Dingo\\Api\\Routing\\Router->dispatch()",
            "#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Dingo\\Api\\Http\\Middleware\\Request->Dingo\\Api\\Http\\Middleware\\{closure}()",
            "#24 /var/www/html/extensions/igniterlabs/visitortracker/middleware/TrackVisitor.php(13): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()",
            "#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): IgniterLabs\\VisitorTracker\\Middleware\\TrackVisitor->handle()",
            "#26 /var/www/html/vendor/tastyigniter/flame/src/Setting/Middleware/SaveSetting.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()",
            "#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Igniter\\Flame\\Setting\\Middleware\\SaveSetting->handle()",
            "#28 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()",
            "#29 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()",
            "#30 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()",
            "#31 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()",
            "#32 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()",
            "#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()",
            "#34 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()",
            "#35 /var/www/html/vendor/fruitcake/laravel-cors/src/HandleCors.php(52): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()",
            "#36 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle()",
            "#37 /var/www/html/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()",
            "#38 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle()",
            "#39 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()",
            "#40 /var/www/html/extensions/igniter/api/vendor/dingo/api/src/Http/Middleware/Request.php(127): Illuminate\\Pipeline\\Pipeline->then()",
            "#41 /var/www/html/extensions/igniter/api/vendor/dingo/api/src/Http/Middleware/Request.php(103): Dingo\\Api\\Http\\Middleware\\Request->sendRequestThroughRouter()",
            "#42 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Dingo\\Api\\Http\\Middleware\\Request->handle()",
            "#43 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()",
            "#44 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\\Pipeline\\Pipeline->then()",
            "#45 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()",
            "#46 /var/www/html/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle()",
            "#47 {main}"
        ]
    }
}
@BaoNguyenSE
Copy link
Author

@ryanmitchell @sampoyigi please help me!

@ryanmitchell
Copy link
Member

Please don't tag people like that. If it's urgent request support from the website, otherwise be patient as this is an open source mostly volunteer led project.

@BaoNguyenSE
Copy link
Author

i so sorry.

@ryanmitchell
Copy link
Member

I just ran a quick test and this works fine for me on 3.2 and the latest versions of all extensions. Can you make sure you're on the latest codebase and if so can you confirm what laravel and PHP versions you are using as there may be a clash there.

@BaoNguyenSE
Copy link
Author

BaoNguyenSE commented Jan 19, 2022

Im sure it latest codebase and Im using php version 7.4.26. and tasty v3.2.1. Thanks you for test.

@ryanmitchell
Copy link
Member

Have you modified the codebase in any way?
What Laravel version is in your composer.lock file?

@BaoNguyenSE
Copy link
Author

Im not modify any codebase. Im using laravelv8.0. Error happen when upgrade project to v 3.2.1

@BaoNguyenSE
Copy link
Author

BaoNguyenSE commented Jan 19, 2022

  • You haved create relation MenuItem to Categories, after i created relation it throw error.
    image

@ryanmitchell
Copy link
Member

Yes. I can see from your screenshot you have made modifications.... you have tax classes there

@BaoNguyenSE
Copy link
Author

Tax Class is different extension.

@ryanmitchell
Copy link
Member

I know, have you tried disabling it to see if thats the issue?

@BaoNguyenSE
Copy link
Author

BaoNguyenSE commented Jan 19, 2022

I just tried disabling the extension and the error still occurs.
Any api index have param include relationship one to many ex: categories, menus,...
image
image

@BaoNguyenSE
Copy link
Author

image
this api get categories with include menus it happen same error

@ryanmitchell
Copy link
Member

@sampoyigi any thoughts? Its working fine for me in all environments. Could it be a WAMP thing?

@sampoyigi
Copy link
Member

I'm unable to reproduce the error, maybe try disabling all third party extensions?

@BaoNguyenSE
Copy link
Author

What laravel version you use?

@shomarim
Copy link

I am also experiencing the same issue.
api/categories/4?include=locations works but
api/categories/4?include=menus does not

TastyIgniter 3.2.2
Laravel 8.80.0
PHP 8.0.12
MariaDB 10.3.32

@BaoNguyenSE
Copy link
Author

@shomarim After many days debug, i found error occur on laravel 8.80, you can downgrade version to 8.74 to fix

@shomarim
Copy link

Thank you @BaoNguyenSE. That worked! I just tried different versions and it seems that the issue occurred with Laravel 8.77. I suspect this PR to be the cause: laravel/framework#40022

@ryanmitchell
Copy link
Member

Thanks for investigating - yes it seems the upstream changes in Laravel have caused this.
@sampoyigi any thoughts on the right way to go about fixing this?

@sampoyigi
Copy link
Member

@BaoNguyenSE thanks for investigating.

@shomarim can you please confirm if this issue still exists on laravel 8.80+, i'm unable to reproduce on 8.82

@sampoyigi
Copy link
Member

Fixed here tastyigniter/flame@ad1dfc0

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

No branches or pull requests

4 participants