warning: implode() [function.implode]: Argument must be an array in .../sites/all/modules/google_analytics/googleanalytics.module on line 484.

Comments

hass’s picture

Status: Active » Postponed (maintainer needs more info)

Hm... is $user->roles not an array? Normally you cannot have no roles... or I thought so. Logged in user or Anonymous?

hass’s picture

I have no clue how you are able to get this warning. If you are logged in, you MUST have at least a role "authenticated user" plus some others and if you are logged out a role "anonymous user". Please write a repro plan.

jannalexx’s picture

Of course there are roles, message only on logged in users, when logging in and when creating or updating content as tested . Unfortunatelly reproduction is not possible but version 3.0 stable does not produce the error. There is a backtrace in case it can tell something

latest dev 17-01-11

a. logging-in

warning: implode() [function.implode]: Invalid arguments passed in .../google_analytics/googleanalytics.module on line 484.
Backtrace:
implode(a:2:{i:0;s:1:",";i:1;N;})[googleanalytics.module:484];
.googleanalytics_token_values(a:3:{i:0;s:4:"user";i:1;N;i:2;a:0:{}})[?:?];
..call_user_func_array(array)[module.inc:483];
...module_invoke_all(array)[token.module:336];
....token_get_values(a:3:{i:0;s:4:"user";i:1;N;i:2;b:1;})[user_stats.module:699];
.....user_stats_login_count_update(a:2:{i:0;s:9:"increment";i:1;s:2:"17";})[user_stats.module:441];
......user_stats_user(array)[user.module:22];
.......user_module_invoke(array)[user.module:1405];
........user_authenticate_finalize(array)[user.module:1378];
.........user_authenticate(array)[user.module:1338];
..........user_login_authenticate_validate(array)[form.inc:780];
...........form_execute_handlers(array)[form.inc:725];
............_form_validate(array)[form.inc:590];
.............drupal_validate_form(array)[form.inc:409];
..............drupal_process_form(array)[form.inc:119];
...............drupal_get_form(a:1:{i:0;s:16:"user_login_block";})[user.module:742];
................user_block(a:2:{i:0;s:4:"view";i:1;s:1:"0";})[?:?];
.................call_user_func_array(array)[module.inc:462];
..................module_invoke(array)[block.module:509];
...................block_list(a:1:{i:0;s:15:"sidebar_outside";})[theme.inc:1626];
....................theme_blocks(a:1:{i:0;s:15:"sidebar_outside";})[?:?];
.....................call_user_func_array(array)[theme.inc:656];
......................theme(array)[theme.inc:1820];
.......................template_preprocess_page(array)[?:?];
........................call_user_func_array(array)[theme.inc:697];
.........................theme(array)[index.php:52];
..........................index.php
warning: array_keys() [function.array-keys]: The first argument should be an array in .../google_analytics/googleanalytics.module on line 485.
Backtrace:
array_keys(a:1:{i:0;N;})[googleanalytics.module:485];
.googleanalytics_token_values(a:3:{i:0;s:4:"user";i:1;N;i:2;a:0:{}})[?:?];
..call_user_func_array(array)[module.inc:483];
...module_invoke_all(array)[token.module:336];
....token_get_values(a:3:{i:0;s:4:"user";i:1;N;i:2;b:1;})[user_stats.module:699];
.....user_stats_login_count_update(a:2:{i:0;s:9:"increment";i:1;s:2:"17";})[user_stats.module:441];
......user_stats_user(array)[user.module:22];
.......user_module_invoke(array)[user.module:1405];
........user_authenticate_finalize(array)[user.module:1378];
.........user_authenticate(array)[user.module:1338];
..........user_login_authenticate_validate(array)[form.inc:780];
...........form_execute_handlers(array)[form.inc:725];
............_form_validate(array)[form.inc:590];
.............drupal_validate_form(array)[form.inc:409];
..............drupal_process_form(array)[form.inc:119];
...............drupal_get_form(a:1:{i:0;s:16:"user_login_block";})[user.module:742];
................user_block(a:2:{i:0;s:4:"view";i:1;s:1:"0";})[?:?];
.................call_user_func_array(array)[module.inc:462];
..................module_invoke(array)[block.module:509];
...................block_list(a:1:{i:0;s:15:"sidebar_outside";})[theme.inc:1626];
....................theme_blocks(a:1:{i:0;s:15:"sidebar_outside";})[?:?];
.....................call_user_func_array(array)[theme.inc:656];
......................theme(array)[theme.inc:1820];
.......................template_preprocess_page(array)[?:?];
........................call_user_func_array(array)[theme.inc:697];
.........................theme(array)[index.php:52];
..........................index.php
warning: implode() [function.implode]: Invalid arguments passed in ...google_analytics/googleanalytics.module on line 485.
Backtrace:
implode(a:2:{i:0;s:1:",";i:1;N;})[googleanalytics.module:485];
.googleanalytics_token_values(a:3:{i:0;s:4:"user";i:1;N;i:2;a:0:{}})[?:?];
..call_user_func_array(array)[module.inc:483];
...module_invoke_all(array)[token.module:336];
....token_get_values(a:3:{i:0;s:4:"user";i:1;N;i:2;b:1;})[user_stats.module:699];
.....user_stats_login_count_update(a:2:{i:0;s:9:"increment";i:1;s:2:"17";})[user_stats.module:441];
......user_stats_user(array)[user.module:22];
.......user_module_invoke(array)[user.module:1405];
........user_authenticate_finalize(array)[user.module:1378];
.........user_authenticate(array)[user.module:1338];
..........user_login_authenticate_validate(array)[form.inc:780];
...........form_execute_handlers(array)[form.inc:725];
............_form_validate(array)[form.inc:590];
.............drupal_validate_form(array)[form.inc:409];
..............drupal_process_form(array)[form.inc:119];
...............drupal_get_form(a:1:{i:0;s:16:"user_login_block";})[user.module:742];
................user_block(a:2:{i:0;s:4:"view";i:1;s:1:"0";})[?:?];
.................call_user_func_array(array)[module.inc:462];
..................module_invoke(array)[block.module:509];
...................block_list(a:1:{i:0;s:15:"sidebar_outside";})[theme.inc:1626];
....................theme_blocks(a:1:{i:0;s:15:"sidebar_outside";})[?:?];
.....................call_user_func_array(array)[theme.inc:656];
......................theme(array)[theme.inc:1820];
.......................template_preprocess_page(array)[?:?];
........................call_user_func_array(array)[theme.inc:697];
.........................theme(array)[index.php:52];
..........................index.php

b. content creation

warning: implode() [function.implode]: Invalid arguments passed in .../google_analytics/googleanalytics.module on line 484.
Backtrace:
implode(a:2:{i:0;s:1:",";i:1;N;})[googleanalytics.module:484];
.googleanalytics_token_values(a:3:{i:0;s:4:"user";i:1;N;i:2;a:0:{}})[?:?];
..call_user_func_array(array)[module.inc:483];
...module_invoke_all(array)[token.module:336];
....token_get_values(a:3:{i:0;s:4:"user";i:1;N;i:2;b:1;})[user_stats.module:781];
.....user_stats_post_count_update(a:2:{i:0;s:5:"reset";i:1;s:2:"17";})[user_stats.module:307];
......user_stats_nodeapi(array)[node.module:679];
.......node_invoke_nodeapi(array)[node.module:932];
........node_save(array)[node.pages.inc:456];
.........node_form_submit(array)[form.inc:780];
..........form_execute_handlers(array)[form.inc:260];
...........ctools_process_form(array)[form.inc:102];
............ctools_build_form(array)[node_edit_form.inc:75];
.............ctools_context_create_node_edit_form(array)[context.inc:564];
..............ctools_context_create(array)[node_edit.inc:37];
...............ctools_node_edit_context(array)[context.inc:757];
................ctools_context_get_context_from_argument(array)[context.inc:813];
.................ctools_context_get_context_from_arguments(array)[context-task-handler.inc:227];
..................ctools_context_handler_get_task_contexts(array)[node_edit.inc:92];
...................page_manager_node_edit(array)[?:?];
....................call_user_func_array(array)[menu.inc:348];
.....................menu_execute_active_handler(a:0:{})[index.php:34];
......................index.php
warning: array_keys() [function.array-keys]: The first argument should be an array in .../google_analytics/googleanalytics.module on line 485.
Backtrace:
array_keys(a:1:{i:0;N;})[googleanalytics.module:485];
.googleanalytics_token_values(a:3:{i:0;s:4:"user";i:1;N;i:2;a:0:{}})[?:?];
..call_user_func_array(array)[module.inc:483];
...module_invoke_all(array)[token.module:336];
....token_get_values(a:3:{i:0;s:4:"user";i:1;N;i:2;b:1;})[user_stats.module:781];
.....user_stats_post_count_update(a:2:{i:0;s:5:"reset";i:1;s:2:"17";})[user_stats.module:307];
......user_stats_nodeapi(array)[node.module:679];
.......node_invoke_nodeapi(array)[node.module:932];
........node_save(array)[node.pages.inc:456];
.........node_form_submit(array)[form.inc:780];
..........form_execute_handlers(array)[form.inc:260];
...........ctools_process_form(array)[form.inc:102];
............ctools_build_form(array)[node_edit_form.inc:75];
.............ctools_context_create_node_edit_form(array)[context.inc:564];
..............ctools_context_create(array)[node_edit.inc:37];
...............ctools_node_edit_context(array)[context.inc:757];
................ctools_context_get_context_from_argument(array)[context.inc:813];
.................ctools_context_get_context_from_arguments(array)[context-task-handler.inc:227];
..................ctools_context_handler_get_task_contexts(array)[node_edit.inc:92];
...................page_manager_node_edit(array)[?:?];
....................call_user_func_array(array)[menu.inc:348];
.....................menu_execute_active_handler(a:0:{})[index.php:34];
......................index.php
warning: implode() [function.implode]: Invalid arguments passed in ...google_analytics/googleanalytics.module on line 485.
Backtrace:
implode(a:2:{i:0;s:1:",";i:1;N;})[googleanalytics.module:485];
.googleanalytics_token_values(a:3:{i:0;s:4:"user";i:1;N;i:2;a:0:{}})[?:?];
..call_user_func_array(array)[module.inc:483];
...module_invoke_all(array)[token.module:336];
....token_get_values(a:3:{i:0;s:4:"user";i:1;N;i:2;b:1;})[user_stats.module:781];
.....user_stats_post_count_update(a:2:{i:0;s:5:"reset";i:1;s:2:"17";})[user_stats.module:307];
......user_stats_nodeapi(array)[node.module:679];
.......node_invoke_nodeapi(array)[node.module:932];
........node_save(array)[node.pages.inc:456];
.........node_form_submit(array)[form.inc:780];
..........form_execute_handlers(array)[form.inc:260];
...........ctools_process_form(array)[form.inc:102];
............ctools_build_form(array)[node_edit_form.inc:75];
.............ctools_context_create_node_edit_form(array)[context.inc:564];
..............ctools_context_create(array)[node_edit.inc:37];
...............ctools_node_edit_context(array)[context.inc:757];
................ctools_context_get_context_from_argument(array)[context.inc:813];
.................ctools_context_get_context_from_arguments(array)[context-task-handler.inc:227];
..................ctools_context_handler_get_task_contexts(array)[node_edit.inc:92];
...................page_manager_node_edit(array)[?:?];
....................call_user_func_array(array)[menu.inc:348];
.....................menu_execute_active_handler(a:0:{})[index.php:34];
......................index.php

jannalexx’s picture

latest dev I have available that worked: googleanalytics.module,v 1.36.2.21 2010/10/09, I guess it points to token
something is wrong/conflict somewhere here

* Implementation of hook_token_values().
* Implementation of hook_token_list().

hass’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new997 bytes

Token support in custom variables will be a new feature in 6.x-3.1. Therefore you cannot see this issues in 3.0...

Here is a patch with some stolen code from token module. I hope this fixes the issue, but I was not yet able to repro it myself. Can you try this patch, please?

hass’s picture

Title: warning: implode() [function.implode]: Argument must be an array in googleanalytics.module on line 484 » User object may not loaded / PHP warnings shown
hass’s picture

Can you also test again with latest token dev (without my patch) first. I will take a look why token does not provide the user object. It may be a bug of token.

hass’s picture

Title: User object may not loaded / PHP warnings shown » User object may not loaded in hook_token_values / PHP warnings shown
hass’s picture

Project: Google Analytics » Token
Version: 6.x-3.x-dev » 6.x-1.x-dev

The more I'm thinking about this issue I believe this may be a bug in token. I've only implemented the hook as documented in the API, and if it's missing the object or it does not provide the full object than token module need to make sure that the object is available and not my hook. What this GA patch does is something that token module should do before it calls the hook with object user and not every single module that implements the token hook. This would be at least for performance reasons a worse idea.

The changed code is also not documented in token module and I do not have any clue why the below code is required.

    if (!empty($object)) {
      $account = $object;
    }
    else {
      $account = user_load(array('uid' => $GLOBALS['user']->uid));
    }

Moving this issue to token queue where it hopefully get seen by Dave very soon.

hass’s picture

StatusFileSize
new1.44 KB

Patch attached for token. Fully untested prove of concept.

@jannalexx: Maybe you are able to give this patch a try, please?

Status: Needs review » Needs work

The last submitted patch, token_D6_user_object_may_not_loaded.patch, failed testing.

jannalexx’s picture

both pathces work, for #10 no error msgs on latest google analytics dev 3.x and token 1.15, i cannot say about other side effects, but the error has been disappeared

hass’s picture

My token patch seems to have a side effect... hopefully one of the token maintainers can shed some light on this.

dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new6.43 KB

This is a tough problem that fortunately we have solved in Drupal 7, but remains a sticky point for D6. Token module itself only defines the following three tokens as 'current user' tokens: [user-name], [user-id], and [user-mail]. There are no other current user tokens defined. All the other 'user' type tokens require a proper user object, which is up to the code calling token_replace() to provide itself. Now the kicker is that we're working around this in user_token_values(). Why? I do not know. It's not defined that those tokens should work for the global user, so we should probably just remove that hack.

xurizaemon’s picture

token_user.inc line 58 in that patch above,

$values['user-raw'] = !$account->uid && !$account->name ? : $account->name;

Is that meant to be anonymous?

$values['user-raw'] = !$account->uid && !$account->name ? variable_get('anonymous', 'Anonymous') : $account->name;

xurizaemon’s picture

dave reid’s picture

Ugh yeah, that's a bug in the patch.

xurizaemon’s picture

If my suggestion in #15 was the intended output, then here's the matching reroll.

(Presumably this got missed by the testbot because the tests don't ever trigger a load of token_user.inc.)

jwilson3’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new5.23 KB

Reroll of #18, which no longer applied against latest 6.x codebase. This definitely fixes the problems.

bluegeek9’s picture

Status: Reviewed & tested by the community » Closed (outdated)