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

Memory size exhausted when exporting Commerce Products #14

Open
HannahDeWachter opened this issue Jul 30, 2024 · 14 comments
Open

Memory size exhausted when exporting Commerce Products #14

HannahDeWachter opened this issue Jul 30, 2024 · 14 comments

Comments

@HannahDeWachter
Copy link

Describe the bug

When trying to export only 45 Commerce Products I get following error:

Allowed memory size of 1073741824 bytes exhausted (tried to allocate 32768 bytes)

This occurs both on local environment and staging environment.

Steps to reproduce

  1. Select Products to export

Craft CMS version

4.7.2

Plugin version

1.0.4

Multi-site?

Yes

Additional context

No response

@engram-design
Copy link
Member

Not something I can replicate on my end, but then I also have only about 12 products available to export. I wouldn't have though the number would make too much of a difference though.

Do you have any custom fields on your Product Type, for Products or Variants? I'm wondering if there's some sort of recursion going on that's unique to your setup.

@HannahDeWachter
Copy link
Author

Hi @engram-design,

I don't work with Variants. My Product Type has following (custom) field types:

  • Lightswitch
  • Redactor
  • Asset (Image)
  • Plain Text
  • Entries
  • Categories
  • SEO Fields

I now also tried exporting an Entries Section with the exact same fields and this also gives the same error. When listing all custom fields, I thought maybe it could be the SEO Fields that would cause the problem, but when trying to export other Entries with this field, there is no error and it downloads the export.

I experienced the same error also when trying to export Entries. However some Sections don't give any problems (even with 129 items) and others do give the same error even when trying to export only 4 items.
The Section where the 129 entries exported without any problems has following field types:

  • Plain Text
  • Matrix
  • Asset (Image)
  • SEO Fields

Another Section giving this error has following field types:
  • Redactor
  • Neo
  • Navigation
  • Plain Text
  • Asset (Image)
  • SEO Fields

@engram-design
Copy link
Member

Thanks for confirming those field types. I've replicated that on my end, but no issues exporting.

Would it be possible to either gain your project config YAML files, or your database? Totally understand if you can't share your database, but if you can either provide your composer.json, composer.lock and config/project files, or alternatively your database, that'd be amazing. You can send this to [email protected].

I'll continue trying to replicate this.

@HannahDeWachter
Copy link
Author

Hi @engram-design

I sent you an e-mail with the composer.json, composer.lock and config/project files.

@engram-design
Copy link
Member

Thanks for sending that through. I did manage to get your site setup and some entries/product elements generated, but exporting things still works on my end.

I'll keep at trying to replicate things.

@HannahDeWachter
Copy link
Author

Hi @engram-design
I did some more testing on my end and even have problems with exporting 1 "Downloads" entry. This section only contains 3 fields: Plain Text, Entries and Assets.

I think the problem may lay at Elements where an Asset field has a value. Could you try this by providing an Asset on one of your entries/products?

@engram-design
Copy link
Member

Thanks @HannahDeWachter yep I've been trying with populated fields for everything, including assets. It's possible the size of an asset could trigger this, but from what I've found, they need to be exceptionally large to do that. Even then, all Zen does is copy them from the asset directory to our zipped export, which doesn't consume memory.

I believe one other user has reported a similar issue with an elements field, so there must be something going on there.

@HannahDeWachter
Copy link
Author

Hi @engram-design

I now tested by removing the 2 Entries field ("Thema's" and "Settings") from the Commerce Products. Now the export works! When re-adding the 2 fields, the export gives the error again.
So the problem may be related to the Entries fields. I did not remove any Assets fields.

@engram-design
Copy link
Member

Thanks! I've created a Settings entry, but might need some guidance on the "Content builder" content for the entry you're testing with. I've added a bunch of different blocks, but no issue so far. All other fields are populated with some content.

@HannahDeWachter
Copy link
Author

@engram-design

When trying to import the export file I just made, I get following error:
Screenshot 2024-08-07 at 10 55 43

This made me remember there is a function added to our database (geoDistance), which may or may not contribute to the initial problem.
The SQL query to add the function to the database:

CREATE FUNCTION `geoDistance`(`long1` float,`lat1` float,`long2` float,`lat2` float) RETURNS int(11)
BEGIN
RETURN ST_DISTANCE_SPHERE(point(long1, lat1), point(long2, lat2));
END

@engram-design
Copy link
Member

It probably won't be an issue with exporting content (just added that myself). As for the error, we'll either need to add a setting to disable backups, or you'll need to address the permissions issue on your end.

Would you be able to let me know what sort of blocks a Settings page is using, in case that's a factor in my reproduction?

@HannahDeWachter
Copy link
Author

Hi @engram-design

The "Settings" field seems to be a Categories field instead of a Entries field, sorry for the confusion. On this Category there is only the Title field.

On the "Thema's" entries I have following blocks:

  • Row
    • Text & Image
  • Row
    • Overview
  • Row
    • One column
    • Overview
  • Row
    • Three columns
  • Row
    • One column
    • Three columns
    • One column
    • Three columns

Here is a screenshot of the first block:
Screenshot 2024-08-07 at 14 28 25

@engram-design
Copy link
Member

Thanks for that. Can I ask what section the "Bewegingsdriehoek" entry is you're linking to? If this is entry/element related, I want to ensure I've got all the parts hooked up.

@HannahDeWachter
Copy link
Author

@engram-design The "Bewegingsdriehoek" entry is in the Thema's section (it's the child of this entry) with as Entry Type "Bewegingsdriehoek".
Here is a screenshot:
Screenshot 2024-08-09 at 09 23 42

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

2 participants