vienthuong / shopware-php-sdk

A PHP SDK for Shopware 6 Admin API
MIT License
112 stars 44 forks source link

Allowed memory size exhausted #78

Open gaxweb opened 1 year ago

gaxweb commented 1 year ago

Content of $response:

Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in <b>/var/www/html/test/shopware6/vendor/shopware/core/Framework/Struct/JsonSerializableTrait.php</b> on line <b>15</b>   
Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 65536 bytes) in <b>Unknown</b> on line <b>0</b>

Happened while executing \Vin\ShopwareSdk\Repository\EntityRepository::search(). Doesn't throw an exception, so difficult to spot. It tried to assign more than 256MB.

Which is strange because I had set ini_set('memory_limit', '1G') earlier. So I guess it's happening on the server side?

$response = $this->decodeResponse($response) just returns an empty response which then causes a misleading exception to be thrown in $aggregations = new AggregationResultCollection($response['aggregations']).

vienthuong commented 1 year ago

from the log I'd say it's the error from the Shopware's platform

gaxweb commented 1 year ago

The point is that I had to dig in and find out why it breaks, and the actual reason wasn't what the thrown exception suggested. I think this might be worth handling by throwing an exception, if the response contains the words "fatal error", so people don't waste time debugging. Or at least trigger an E_USER_WARNING or something, 'cause it might be a valid sub-string in the user data.

vienthuong commented 1 year ago

That totally makes sense :) Feel free to create a PR or I might take care of it later