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

emptyvoid’s picture

I'm not aware if the $custom_url is not set what repercussions that will cause.

hass’s picture

Status: Active » Postponed (maintainer needs more info)

How is it possible that tnid is set in this case?

hass’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

I 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.

hass’s picture

Issue summary: View changes

trying to fix formatting.