bagisto / headless-ecommerce

Laravel Headless eCommerce APIs allow you to experience seamless and easily scalable storefront performance. An open-source and GraphQL based Rest API Laravel platform delivering ultra-fast, dynamic, and personalized shopping experiences.
https://bagisto.com/en/headless-ecommerce/
MIT License
72 stars 44 forks source link

PHP error for image upload #276

Closed Diverti closed 1 month ago

Diverti commented 1 month ago

HI!

I found a small issue. When i tried to upload an image, i got an exception: { "errors": [ { "message": "Internal server error", "locations": [ { "line": 2, "column": 13 } ], "path": [ "uploadImage" ], "extensions": { "debugMessage": "Only variables should be passed by reference", "file": "C:\\laragon\\www\\devbagisto\\vendor\\bagisto\\graphql-api\\src\\BagistoGraphql.php", "line": 768, ........

So this is the line 768 of graphql-api\src\BagistoGraphql.php: $ext = strtolower(array_pop(explode('.', $filename)));

should be replaced by this: $parts = explode('.', $filename); $ext = strtolower(array_pop($parts));

Initially, if you save the result of explode() in a variable, then this variable can be sent as reference to array_pop(). This approach eliminates the direct function call problem, thus, satisfying PHP's requirement for the passing of references.

mayank-webkul commented 1 month ago

Hi @Diverti This issue is already fixed in the main branch.

Diverti commented 1 month ago

I see, thank you for your anwser, i close this issue then.