Closed (duplicate)
Project:
Google Analytics
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Mar 2012 at 21:35 UTC
Updated:
18 Apr 2012 at 19:38 UTC
Experiencing an error on nodes for a content type where multilingual translation is supported. When the node is created it isn't set to a specific language (even though it appears as English).
On line 165 of google_analytics.module the $source_node object returns false. Meaning it can't load, so the following error is generated.
Notice: Trying to get property of non-object in googleanalytics_page_alter() (line 167 of /var/www/example/code/sites/all/modules/contrib/google_analytics/googleanalytics.module). Backtrace:
googleanalytics_page_alter(Array, NULL, NULL) module.inc:1018
drupal_alter('page', Array) common.inc:5582
drupal_render_page(Array) common.inc:2582
drupal_deliver_html_page(Array) common.inc:2470
drupal_deliver_page(Array, '') menu.inc:532
menu_execute_active_handler() index.php:21
I added a check for the $source_node object to not be false.. and the error goes away.
163: $node = menu_get_object();
164: if ($node && translation_supported_type($node->type) && isset($node->tnid) && ($node->tnid != $node->nid)) {
165: $source_node = node_load($node->tnid);
166: $languages = language_list();
167: if ($source_node) {
168: $url_custom = drupal_json_encode(url('node/' . $source_node->nid, array('language' => $languages[$source_node->language])));
169: }
170: }
Comments
Comment #1
emptyvoid commentedI'm not aware if the $custom_url is not set what repercussions that will cause.
Comment #2
hass commentedHow is it possible that tnid is set in this case?
Comment #3
hass commentedI changed http://drupalcode.org/project/google_analytics.git/commit/343b1b7 some time ago. Have you tested with DEV? If it does not work, please reopen.
Comment #3.0
hass commentedtrying to fix formatting.