Whenever metatags and ubercart are installed, a product view page will invoke uc_product_add_to_cart_form twice instead of once, so hook_form_alters on that form will be called twice. Also, the product edit page will invoke uc_product_add_to_cart_form for that node when it should not.

The problem seems to stem from _nodewords_prepare whenever nodewords_description_prepare() is called. I don't really know how this module works, but it appears as if whatever is in an Ubercart Product's description causes hook_form_alter() to be called whenever it is prepared.

I guess normally this behavior does not cause a problem, but it was first reported to me here http://drupal.org/node/261662 because I have a module which adds some AJAX code whenever a uc_product_add_to_cart form is loaded, and when combined with metatags it will add this code to a product edit screen via hook_form_alter but then throw javascript errors since the form that it is triggered by doesn't actually appear on that page.

Comments

jantoine’s picture

Title: Incompatibility with Ubercart Product Nodes » Loading node/view only forms when node/edit is visited
Version: 5.x-1.8 » 5.x-1.9

After further research, it appears the nodewords_description_prepare() is loading node/view only forms when a node/edit screen is visited.

For example, lets say you have a product stored in the database as node 1. Each product has an "Add to Cart" form that is only loaded on node/view, in this case node/1/view. When visiting the node/1/edit screen with the nodewords module loaded, the node specific "Add to Cart" form is being loaded. When this happens with the uc_aac module loaded, a JavaScript error is thrown that causes all further JavaScript processing to halt. This then is causing the FCKeditor to not load.

This is a ubercart product specific example, but this should be reproducible in similar situations. I am currently trying to create a patch for this issue, but I am fairly new to Drupal and don't quite understand the entire Drupal coding style. Anyone who can look at this issue with me or point me in the right direction is greatly appreciated

Cheers,

Jon Antoine

jantoine’s picture

Title: Loading node/view only forms when node/edit is visited » Calls to node_build_content() from nodewords_description_prepare() are causing duplicate loading of node information
Version: 5.x-1.9 » 5.x-1.x-dev
Priority: Normal » Critical

The Nodewords (Meta Tags) module offers the option to "Use the teaser of the page if the meta description is not set." Leaving this option selected by default causes the module to load the entire teaser view so they can pull the teaser for the meta description. This includes loading any forms that belong only to the teaser.

I am new to Drupal so I don't claim to know a better way of doing things, but this seems like a lot of overhead just to pull teaser information from a node for the meta description? I have also found other issues that are directly related to this bug and have listed them below.

http://drupal.org/node/153295
http://drupal.org/node/179362

An obvious workaround is to uncheck the "Use the teaser of the page if the meta description is not set." option. One can also always input meta information manually which will also keep the Nodewords module from loading the teaser.

Cheers,

Jon

apaderno’s picture

Priority: Critical » Normal
Status: Active » Closed (won't fix)

I am lowering the priority, as there is the possibility to disable the creation of the description meta tag from the node teaser.

As the Drupal 5 version is not supported anymore, I am changing the status of this report.

hanoii’s picture

Version: 5.x-1.x-dev » 6.x-1.0
Status: Closed (won't fix) » Active

Sorry to bring this issue back to life. This happens on 6.x as well.

Also have a module (uc_out_of_stock) that does some AJAX and also I just found a conflict first generated by this module. While I will create a workaround, I think this is something that should be addressed. I love nodewords, but I think that's behavior is not the best one to follow. Executing the whole node_build_prepare() just to get the description of the node seems to be a bit too much and it definitely is making things run twice. What I found, for instance, is that the add to cart form is appended with a -1 to the ID, just because the same one was already loaded and rendered, although never output.

Maybe how to obtain the description of the node can be done somewhere in a nodeapi hook with some static variables?

apaderno’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
Status: Active » Fixed

node_build_content() is not used anymore in the development snapshot. As there isn't a way to correct the code present in an official release, if not creating a new official release (and considering that the code that will be the base for the next official release has been already changed), I am changing the referring version, and the status of this report.

apaderno’s picture

Issue tags: +6.x-1.0

I am tagging this report to add it in the list of the differences between version 6.x-1.0 and the next official release.

Status: Fixed » Closed (fixed)

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