At the moment uc_node_checkout_form_alter() executes uc_node_checkout_product_map() for every form on the website. This will chew resources without purpose. I've rolled a patch to prevent this happening when the majority of forms are displayed. Resource chewing will still happen on forms with an ID ending in '_node_form'. Patch to follow.

Comments

sammys’s picture

Status: Active » Needs review
StatusFileSize
new11.84 KB

Patch attached

sammys’s picture

StatusFileSize
new12.17 KB

Ignore this patch. The name was wrong.

sammys’s picture

StatusFileSize
new12.17 KB

Here's a patch to use when patch in #771934: Add "Cancel" link to node add form buttons is applied first.

kmonty’s picture

Status: Needs review » Reviewed & tested by the community

I would prefer wrapping the function with if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {, but either one works. Let's get this committed.

aidanlis’s picture

Status: Reviewed & tested by the community » Needs work

$ git apply 771934_201004151800+1000.patch
771934_201004151800+1000.patch:146: trailing whitespace.

771934_201004151800+1000.patch:155: trailing whitespace.

771934_201004151800+1000.patch:161: trailing whitespace.

771934_201004151800+1000.patch:173: trailing whitespace.

771934_201004151800+1000.patch:184: trailing whitespace.

error: patch failed: uc_node_checkout.module:288
error: uc_node_checkout.module: patch does not apply

Could you please re-roll your patch? It's very unclear what you've changed and it does not apply cleanly. Instead of wrapping everything in a giant if(), use return or break it into a separate function.

aidanlis’s picture

Status: Needs work » Postponed (maintainer needs more info)
sammys’s picture

All I did was surround the code with an if statement restricting it to run only when needed rather than every call to hook_form_alter().

tr’s picture

Status: Postponed (maintainer needs more info) » Fixed

Patch didn't apply because the trailing whitespace in the original code has been removed sometime in the > 1 year since the patch was first rolled.

Ryan ought to be flogged with a wet noodle for that newbie mistake in hook_form_alter(). And for letting the patch languish for so long. Patch makes the important and vital change to execute that block of code *only* for node forms, not for every single form on the site.

Committed to the 6.x-2.x and 7.x-2.x branches. Thanks @sammys.

Status: Fixed » Closed (fixed)

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