I think there may be some recursion happening adding the bundle product type editing links? I remember this was a problem previously.

This is now giving me database timeout messages. Here's a fragment of the attached SQL Insert statement into menu_router:

a:5:{i:0;s:16:"commerce_product";i:1;s:15:"training_bundle";i:2;s:184:"commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_attribute_view";i:3;s:11:"user_access";i:4;s:24:"administer product types";}

Comments

olafkarsten’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

Hi derekw, we appreciate your reports, but we need the steps to reproduce the problem. If we can't reproduce a problem, we can't fight against it.

jeffschuler’s picture

Status: Postponed (maintainer needs more info) » Active

I'm experiencing this too.

Looking through backups, I see that my database has had this recursive mess for awhile, but it didn't start to actually affect things -- slowing down the site considerably, and erroring and timing out as derekw is seeing -- til recently.

I think this newer phase didn't start to happen until I added a couple new product types.

I've rolled back to before those new product types and am not experiencing the problem any more, though I still see the mess in the database.

I can't offer steps to reproduce this issue yet, but I hope we can try to track down why this is happening.

In my DB's menu_links table I see, for each product type:

admin/commerce/products/types/*/display

admin/commerce/products/types/*/display/full
admin/commerce/products/types/*/display/attribute_view
admin/commerce/products/types/*/display/commerce_line_item_display

admin/commerce/products/types/*/display/commerce_product_full
admin/commerce/products/types/*/display/commerce_product_attribute_view
admin/commerce/products/types/*/display/commerce_product_commerce_line_item_display

admin/commerce/products/types/*/display/commerce_product_commerce_product_full
admin/commerce/products/types/*/display/commerce_product_commerce_product_attribute_view
admin/commerce/products/types/*/display/commerce_product_commerce_product_commerce_line_item_display

admin/commerce/products/types/*/display/commerce_product_commerce_product_full
admin/commerce/products/types/*/display/commerce_product_commerce_product_attribute_view
admin/commerce/products/types/*/display/commerce_product_commerce_product_commerce_line_item_display

admin/commerce/products/types/*/display/commerce_product_commerce_product_commerce_product_full
admin/commerce/products/types/*/display/commerce_product_commerce_product_commerce_product_attribute_view
admin/commerce/products/types/*/display/commerce_product_commerce_product_commerce_product_commerce_line_item_display

[all the way up to…]

admin/commerce/products/types/*/display/commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_full
admin/commerce/products/types/*/display/commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_attribute_view
admin/commerce/products/types/*/display/commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_line_item_display

Where in place of the "*" is the name of a product type -- one row for each.

Then, immediately following (in the same table):

admin/commerce/products/types/product/display/commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_line_item
admin/commerce/products/types/product/display/commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_node_full
admin/commerce/products/types/product/display/commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_node_rss
admin/commerce/products/types/product/display/commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_commerce_product_node_teaser

[…]

admin/commerce/products/types/*/display/commerce_product_commerce_product_node_full
admin/commerce/products/types/*/display/commerce_product_commerce_product_line_item
admin/commerce/products/types/*/display/commerce_product_commerce_product_node_rss
admin/commerce/products/types/*/display/commerce_product_commerce_product_node_teaser
admin/commerce/products/types/*/display/commerce_product_commerce_product_node_teaser

admin/commerce/products/types/*/display/commerce_product_full
admin/commerce/products/types/*/display/commerce_product_line_item
admin/commerce/products/types/*/display/commerce_product_node_full
admin/commerce/products/types/*/display/commerce_product_node_rss
admin/commerce/products/types/*/display/commerce_product_node_teaser

admin/commerce/products/types/*/display/full
admin/commerce/products/types/*/display/line_item
admin/commerce/products/types/*/display/node_full
admin/commerce/products/types/*/display/node_rss
admin/commerce/products/types/*/display/node_teaser

The menu_router table shows similar stuff.

olafkarsten, I believe that the db snapshot I provided you with a couple weeks ago shows all of this.

olafkarsten’s picture

okay, something is going wrong, but why do you think it is the bundle module? We didn't touch the product type creation code. It's plain commerce core. Nevertheless I created a handful product types - setup as bundles - created product bundles from it - all on a fresh commerce kickstart install. Works like expected. So I have slight doubts, if we really have a bug here.

olafkarsten’s picture

I can get my database to this state too ;), but missed the moment when it happens :(. But it seems something in creating/editing product types. I'm pretty sure this is not caused by the product bundle module. Nevertheless I will try to reproduce this and get an idea where it comes from.

spuky’s picture

I have been bitten by that Problem too, it seems to come up when Drupal ist for some reason (installing new modules.. clearing cache ... is rebuilding the Menurouter... and the fields_ui is returning a multitude of viewmodes for commerce_products )

to get rid of the result I patched the core fields ui module... to not return them... but this is just fixing the Result of the Problem I will digg deeper as soon as possible...

olafkarsten’s picture

Priority: Normal » Major

Can't find the culprit, but raise the Prio.

olafkarsten’s picture

Hmm, I didn't understand what's going on. But I could narrow down the problem. It happens somewhat with the view_modes, if product references are involved in the product type. I have to test, if this happens without the bundle module enabled.

olafkarsten’s picture

Title: Bundle crashing the menu system » multiple product references on a product type crashes the menu system
Priority: Major » Normal

It happens if one add at least two product reference fields to a product type.

I think it happens when a product display with a product of these very product type is added. However, I'm not entire sure about this. We have to test this against a clean install and observe exactly when it happens. Then we can determine exactly what's needed to reproduce the error and ask some of the commerce core developer to have a look at this issue.

olafkarsten’s picture

Okay, here are the steps to reproduce the problem on a fresh commerce kickstart install (including the product samples, without any other module enabled).

1) Add a second product type.
2) Add two product reference fields to the new product type.
- On 'Product types that can be referenced' check the other type. This should be 'Product' on a clean installation.
3) Clear the cache to rebuild the menu (drush cc menu)
4) Have a look at the database tables menu_router, menu_links
SELECT * FROM `menu_links` WHERE `router_path` LIKE '%commerce_product_commerce_product%'
SELECT * FROM `menu_router` WHERE `path` LIKE '%commerce_product_commerce_product%'

You get some 16 rows or so and see the cluttered path. With each product reference (even if they are attached to other product types) things get more and more worth. (See #2)

I think we can invite now some of the commerce developer to help us. Maybe we should move this issue in the issue queue of commerce module.

jeffschuler’s picture

Project: Commerce Product Bundle » Commerce Core
Component: Code » Product reference

Moving to Commerce queue, as this happens without Bundle installed.

olafkarsten’s picture

I didn't have the skills to solve the issue. If someone of the commerce dev's would point me somewhere :D, i would try to help.

I guess it's somehow related with the extra field code, but i'm completely unsure ...

mr.baileys’s picture

Status: Active » Needs review
StatusFileSize
new873 bytes
new56.23 KB

I have been able to reproduce this by adding a Commerce Product Type and some Commerce Product Reference fields as outlined in #9. The menu_links and menu_router records are one indication of the problem, the bug also manifests itself in the "Custom Display"-section on the "Manage Fields"-page for the entities containing the product reference fields:

commerce-views-mode-crazyness.png

I believe the issue is caused by commerce_product_reference_entity_info_alter.

This function cycles through all entities containing a product reference field, and for each one, copies all view modes from the that entity to the commerce_product entity. There is a bug in the query used to determine referencing entities (product displays) though, causing the copy operation to be executed once for each product reference field per entity.

At least that's what I think happens, still trying to better grok Commerce entities.

Patch attached.

mr.baileys’s picture

Title: multiple product references on a product type crashes the menu system » Multiple product reference fields can cause incorrect view modes on Product entity.

attempt to come up with a more suitable title.

spuky’s picture

Status: Needs review » Reviewed & tested by the community

Nice Catch...

I applied the Patch from #12 and removed my "keep Drupal working" workaroud core Patch that I mentioned in #5 things are Working

No overflow in the menu System... since I got about 12 Product references on a Product type this one was hurting me bad...

olafkarsten’s picture

thanks for that mr.baileys. I can confirm that #12 works.

jeffschuler’s picture

Thanks mr.baileys!!
Also confirmed it fixes via the process in #9.
About to try on a couple sites with which I was experiencing this issue, too.

jeffschuler’s picture

After patching you'll obviously want to:

DELETE FROM `menu_links` WHERE `router_path` LIKE '%commerce_product_commerce_product%';
DELETE FROM `menu_router` WHERE `path` LIKE '%commerce_product_commerce_product%';

and clear the cache to remove existing crud, but it's looking good so far.

mr.baileys’s picture

I think this clean-up is automatically performed when menu_rebuild() runs, so visiting update.php or the modules page should do the trick?

dpolant’s picture

Patch #12 works.

rszrama’s picture

Status: Reviewed & tested by the community » Fixed

Ok, to be honest, this bug makes my head hurt. It's almost silly to even create product view modes for reference fields attached to products, but with the distinct query that should only happen once now avoiding the errors. Thanks for digging this up, my.baileys. You da man!

Thanks to all for the reviews. Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

misidentified suspect module