Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
So, here's what's going on on my site:
{commerce_customer_profile} contains about 30K records with uid = 0;
So, any time I'm clearing cache or doing something that fires commerce_customer_match_customer_profiles(), PHP runs out of memory.
I patched the default $limit argument to 25, and the issues goes away.
Do I need to figure out why/how the profiles are getting created with uid = 0?
Profiles seem to be working fine despite this.
Filing this as a bug, but I will re-post to drupalcommerce.org if you feel it's a support request.
edit: uid = 0, not uid = 1
Comment | File | Size | Author |
---|---|---|---|
#2 | commerce_customer-limit_profile_loading-1910932.patch | 1.05 KB | AaronBauman |
Comments
Comment #1
rszrama CreditAttribution: rszrama commentedlol - Yeah, I'd figure out how you got 30k entries. : D
That said, can you share the patch? Sounds like a reasonable fix.
Comment #2
AaronBaumanThis site has 2 different profile types, 9K users, and 25K orders.
So, the 30K number is not far from what I expected.
I'm guessing the issue is having 29K of the 30K profiles are assigned to uid 0.
During cache clear, commerce is trying to load customer profiles by uid and obliterating PHP's memory limit.
Quick and dirty patch attached.
So far I haven't noticed any odd behavior, even though all the profiles are assigned to uid 0.
user_load() still assigns the appropriate commerce_profile even though the uid doesn't match.
So I guess my next question is, why bother with uid at all?
Comment #3
rszrama CreditAttribution: rszrama commentedAhh, you know, I thought it was 30k for uid 1 for some reason. That said, it's interesting to me that you'd have anonymous customer profiles - they should be getting updated to the uid of the order during the checkout completion process. Have you disabled those rules?
And where is the customer profile match code being called for uid 0?
Comment #4
AaronBaumanthe original issue i posted said uid 1 (see edits above), but I checked again and it's actually uid 0.
This is making sense now that you bring up rules.
The assignment rules are not disabled, but the orders in question are created programatically using entity_create_stub_entity() and saved via commerce_order_save().
The only checkout rules being invoked (again, programatically) are 'commerce_cart_product_add' and 'commerce_checkout_complete'.
All the orders in question have a matching uid, even though the profiles for those same orders have uid = 0.
Thinking this through, order->uid must already assigned when the rule commerce_checkout_order_convert gets invoked, preventing the uid assignment action from firing.
Anyway, looks like commerce_customer_match_customer_profiles() is getting called when commerce's rules get rebuilt on a cache clear.
Here's the stacktrace.
(This "cc all" is called from drush, but results of clearing cache through the UI were the same.)
Comment #5
rszrama CreditAttribution: rszrama commentedI'm not sure of the best solution here, but it seems a limit is in order and doesn't adversely affect any tests at least. I'm going to up it to 50 and commit (with a similar fix to the product matching functions just to be safe), and for your custom code, I generally recommend using our entity specific *_new() functions and would look into why your uids aren't being set properly. Good luck!
Commit: http://drupalcode.org/project/commerce.git/commitdiff/fdce722
Comment #7
Zac_JH CreditAttribution: Zac_JH commentedHi
It took me a while to track this down. But this patch causes an unfortunate result if you have greater than 50 products that can be shown in the product reference field by a product display and you're not using the autocomplete widget.
Perhaps the fix is to amend the function calls in the product reference rather than the limit introduced in product.
Hopefully it'll help other people find this if it's affecting them by adding this text:
drupal commerce product display product reference showing limited 50 products
Comment #8
rszrama CreditAttribution: rszrama commentedPlease see #1925222: Revisit the product query limit introduced in Commerce 7.15.
Comment #8.0
rszrama CreditAttribution: rszrama commentededit: uid = 0, not uid = 1