The hook_node_info() prototype doesn't include any arguments. However, there is one for uc_product_node_info($reset = FALSE).

uc_product_node_info() saves its data in a static function variable so that if it is called twice, it doesn't need to reload its data.

Unfortunately, if an Ubercart node type changes in {node_type} between calls to uc_product_node_info(), the second call will return the static (incorrect) information. This causes Drupal's _node_types_build() to think that the modified record is not attached to any module, so it marks the modified record as disabled, which causes all sorts of problems.

Fortunately, the solution is simple. Just change

function uc_product_node_info($reset = FALSE) {

to

function uc_product_node_info($reset = TRUE) {

This causes the function to re-generate its info every time it is invoked from outside Ubercart. Calls within Ubercart can pass the FALSE.

I'll see if I can make a patch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dan Z’s picture

Version: 7.x-3.x-dev » 7.x-3.2
FileSize
460 bytes

Ok, here's a patch.

To reproduce the problem.

To test the patch, just restore your database and repeat the above, and note that admin/structure/types now shows correct node type info and the DB record is correct and not disabled..

Now, let's see if this patch works.

Dan Z’s picture

Version: 7.x-3.2 » 7.x-3.x-dev
Status: Active » Needs review
FileSize
384 bytes

A more performance-friendly (but riskier) way to do this is to put a call to uc_product_node_info(TRUE) into uc_product_node_type_update() after it updates {uc_product_classes}. That will force it to reload its static data when the node type changes. My test shows that this works.

I'm switching this to -dev to pick up #1831900, so this might make the testbot fail on the patch in #1. It's currently showing that it passed.

longwave’s picture

Version: 7.x-3.2 » 7.x-3.x-dev
FileSize
1.55 KB
1.15 KB

Added a test that covers the manual steps in #1.

longwave’s picture

Status: Needs review » Fixed

Committed, thanks for tracking this down and providing the patch.

Status: Fixed » Closed (fixed)

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