I get the mentioned error when i enable Google Analytics module. I believe the problem is PHP5.3.1 which i have running the website.

At this point module is unusable, so i had to take it off as its unacceptable to have such message displayed to users.

Im looking forward to solution.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hass’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

This seems not to be the complete error message. Write down how to repro, please.

culturehub’s picture

I see the same problem. As soon as the module is enabled, I get the following error message on every page.

Parameter 1 to profile_load_profile() expected to be a reference, value given in /path/to/web/root/includes/module.inc on line 462

No choice but to disable the module. Running PHP 5.3.0 and Drupal 6.15.

culturehub’s picture

I did what this guy did, http://drup.org/drupal-and-php-53

Change
$p = module_invoke('profile', 'load_profile', $user);
to
$p = call_user_func('profile_load_profile', $user);

Worked for me.

hass’s picture

Sounds like a core bug

iva.dcc’s picture

cool, i did similar thing, except that i changed

$p = module_invoke('profile', 'load_profile', $user);

to

$p = module_invoke('profile', '_load_profile', $user);

and the error went away, but i still disabled it, because i am not sure about the repercussions of the change.

jamuraa’s picture

You cannot use module_invoke to pass by reference, which is what the profile_load_profile needs in order to work (it modifies the $user argument). This isn't going to be fixed any time soon - see http://drupal.org/node/353494 scheduled for Drupal 8.x.

The entire error message is:
warning: Parameter 1 to profile_load_profile() expected to be a reference, value given in /var/www/test-site3/includes/module.inc on line 450.

Repro is easy:
1. Set up drupal on a site running PHP 5.3
2. Enable Google Analytics module.

I've fixed it by using profile_load_profile directly like so:
$p = profile_load_profile($user)

There is a secondary bug, which is that this profile_load_profile is loaded even when you don't have segmentation turned on for any user profiles. If there aren't any profiles checked, you could avoid the call alltogether by checking the size of the $profile_fields array before loading up the profile - if it is 0, then no need to load the profile to check the values.

@5: I think modifying it in that way disables the profile loading alltogether, so if you were using user profile segmentation, it would be disabled by the code change.

Catx’s picture

Same problem since 3 days. Actualy why warning occur. Which module i'll have to disable? Adsense, or which? Please tell me in easy way. If above code to use then where i write and page located. In details please.

jamuraa’s picture

FileSize
786 bytes

Patch attached to fix this bug.

hass’s picture

Sounds more and more like a core bug to me. Module invoke schould invoke all modules that have profile load hooks and not only the profile module. As module invoke is a core api function, this is a bug in core.

hass’s picture

Project: Google Analytics » Drupal core
Version: 6.x-2.2 » 6.15
Component: Code » base system
Status: Postponed (maintainer needs more info) » Needs work
hass’s picture

Issue tags: +PHP 5.3

Tagging

Berdir’s picture

Project: Drupal core » Google Analytics
Version: 6.15 » 6.x-2.2
Component: base system » Code
Status: Needs work » Needs review
Issue tags: -PHP 5.3

You can't use module_invoke_all() or module_invoke() for functions that contain by reference arguments, instead, you have to call the function directly or with $function. This is not a Drupal core issue since the argument needs to be by reference but a PHP problem related to call_user_func_array().

You're not using module_invoke_all() so I don't understand your comment in #9, you only call profile.module. The only thing that module_invoke() does more than the direct call is check of the function is available.

If you want to call all load_profile() "hooks", you need to use a custom foreach loop with module_implements:

$hook = 'profile_load';
$profile_fields = array();
foreach (module_implements($hook) as $module) {
  $function = $module . '_' . $hook;
  $profile_fields = array_merge($profile_fields, $function($user));
}

But again, you're not doing that currently either.

Berdir’s picture

Issue tags: +PHP 5.3

Crosspost...

hass’s picture

Looks like you have found a bug :-). Never tested it as there was no other module that provided the profile_load hook, but we need this for #214560: Extend user object like profile module does or #654632: Compatibility with Google Analytics' advanced segmentation - whatever get's in earlier.

iva2k’s picture

subscribe

Catx’s picture

I try everything. And search everything in drupal. I apply patch too. At last i remove analytic from module. That many bug so error. Plz reply if anyone has good working site of analytic module for php 5.3. I wait.

b3liev3’s picture

I've applied that pach and it seems to work fine.

jackbravo’s picture

Yup, I applied the patch too and seems to work ok.

hass’s picture

Status: Needs review » Needs work

@culturehub: #3. I cannot test this now as I do not have PHP 5.3 dev environment yet, but if it solves the issue it may be the fix here. May be broken if the profile module is disabled.

@jamuraa: #8. Needs work as it should break the site if the profile module is disabled.

@Berdir: #12. As I understood this line of code taken over from very very old code... was to execute one function that populates the $user object and than only use the user object and do not fill another variable with the same content... I need to think more about this...

kwinters’s picture

The patch #8 isn't quite complete because it doesn't validate that the module is enabled / the function exists. However it's the right general idea. is_callable maybe?

Berdir in #12 is correct about this not being a core issue (not that it even matters, since a workaround is still required before that core change would even be possible to make in D8+).

bryanb229’s picture

Subscribing.

hass’s picture

Version: 6.x-2.2 » 7.x-1.x-dev
Status: Needs work » Needs review
FileSize
1.28 KB

I tried to use the code in #12, but it seems to do something that was not the intention of the current code and only returns NULL.

      $hook = 'user_load';
      $profile_fields = array();
      foreach (module_implements($hook) as $module) {
        $function = $module . '_' . $hook;
        $profile_fields = array_merge($profile_fields, $function($user));
      }
      krumo($profile_fields);

Now updated the D7 version and added some comments. I have not tested this under PHP 5.3, but it works well for me under 5.2.

hass’s picture

FileSize
1.24 KB

Optimized version.

hass’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
FileSize
1.23 KB

Also a bit cleanup for D6

hass’s picture

FileSize
1.23 KB

again

hass’s picture

Version: 6.x-3.x-dev » 7.x-1.x-dev
FileSize
2.96 KB

@jamuraa: Patch stops now running the module invoke if there are no profile fields selected for tracking.

hass’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
FileSize
3.63 KB
hass’s picture

Version: 6.x-3.x-dev » 7.x-1.x-dev
Status: Needs review » Fixed

Commited

hass’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
Status: Fixed » Needs review
hass’s picture

Status: Needs review » Fixed

Also commited D6 code to 2.x and 3.x

hass’s picture

Status: Fixed » Postponed (maintainer needs more info)

I guess this code changes may not fixed the warning issue the case was opened for... not sure. You need profile module enabled and at least one field to track and PHP 5.3. But I cannot remove a reference in the core hook profile_load_profile(&$user) and I do not see why I'm responsible for this... not sure if we need to write a special function like user_module_invoke('load', $array, $user); to get rid of the warning.

hass’s picture

Status: Postponed (maintainer needs more info) » Fixed

Cannot repro the warnings. Please try again with latest DEV.

I have tested this with xampp 1.7.3 with PHP 5.3.1 and if ($errno & (E_ALL)) { in common.inc with the latest 3.x I'm not able to see any warnings if 'User roles' are enabled for tracking.

Status: Fixed » Closed (fixed)

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

DarrellDuane’s picture

I was getting these warnings and Patch 27 fixed my site. Drupal 6.17, Google Analytics 6.x-2.2, PHP: php-5.3.2-2.fc13.x86_64

mari3.14’s picture

Sorry, just got Google Analytics installed and I am getting the same warning:
warning: Parameter 1 to profile_load_profile() expected to be a reference, value given in /includes/module.inc on line 483.

If I unable Profile in Core and leave Google Analytics on, the warning doesn't appear. Or the other way around, Profile enable and Google Analytics off, the warning is not there. But with both enabled the warning appears.

Running:
Drupal 6.17
Google Analytics 6.x.3.x-dev (which has patch 27 on it already)
PHP 5.3

Wondering...

hass’s picture

Cannot repro... Are you really using the latest dev?

mari3.14’s picture

thanks for coming back to me so quickly hass.

Yes, I just checked again and I got version 6.x-3.x-dev.

I have a testing server where I have just reproduced the error. How strange. I would be very happy to give you User 1 Access to that site if you have a private email I can send the details to. I am happy for you to play around with it if that helps.

Cheerio,
Maria

hass’s picture

I guess it's more a php settings difference...

mari3.14’s picture

Maybe..., nobody else seems to have the same problem so I wonder.

At home I have just upgraded my MAMP to the latest free version available which runs PHP 5.3.2. My hosting service is also running 5.3.2. The warning shows in both.

I will keep an eye on this post to see if anybody has any suggestions. Puzzeling! ;o)

Thanks
Maria

greg.harvey’s picture

It's difficult to follow what's going on here. Did anyone post a 6.x-2.2 patch? 6.x-3.x is all very well, but the recommended version is 6.x-2.2 and I need to patch that...

Edit: I see #8 *is* against 6.x-2.2, works for me. =)

a5342346’s picture

i seem to be getting this error, as well (which is how I ended up here):

Warning: Parameter 1 to profile_load_profile() expected to be a reference, value given in module_invoke() (line 462 of /path/to/includes/module.inc).

however, I do NOT have GoogleAnalytics module installed!

is there a known other/additional cause?

greg.harvey’s picture

Status: Active » Closed (fixed)

Search your code for module_invoke('profile', 'load_profile', $user) - you'll probably find some other module you have installed has the same bug.

Edit: It might also be a module_invoke_all() causing the problem, so it might be good just to look for 'load_profile'.

grub3’s picture

IMHO a new stable release should be made.
I had a lot of error messages before I realized I had to upgrade to google analytics dev.

grub3’s picture

Priority: Normal » Critical

Setting priority to critical.
I will not reopen this bug, but I would like to ... just to have a stable release.

hass’s picture

Priority: Critical » Normal

A wrong php config is no reason for making anything critical

markhalliwell’s picture

I am not reopening this, but I figured that if anyone else is having issues, it might be because you also have the WYSIWYG module as well. It took me weeks to try and track down why I kept seeing this error:

Parameter 1 to profile_load_profile() expected to be a reference, value given in /Volumes/Disk2/jsd/includes/module.inc on line 483.

Which I then realized it's because #12 is right. So I used his code to replace the "accepted" patch, but ran into:

Illegal offset type in isset or empty in /Volumes/Disk2/jsd/sites/all/modules/wysiwyg/wysiwyg.module on line 596.

It turns out, that the WYSIWYG module implements an internal function named: wysiwyg_profile_load($format). Obviously the foreach method in #12 works just fine, but because we're passing the $user object, we get the above error because arrays and objects cannot be keys.

So, for those who need a working solution, even if it is temporary, use the following:

      // Line 100 of googleanalytics.module
      $profile_fields = variable_get('googleanalytics_segmentation', array());
      if (!empty($profile_fields) && ($user->uid > 0)) {
        $hook = 'profile_load';
        $modules = module_implements($hook);
        foreach ($modules as $module) {
          if ($module == 'wysiwyg') continue;
          $function = $module . '_' . $hook;
          $profile_fields = array_merge($profile_fields, $function($user));
        }
      }

      $fields = array();
      foreach ($profile_fields as $field => $title) {
        $fields[$field] = is_array($user->$field) ? implode(',', $user->$field) : $user->$field;
      }

I will be creating a ticket for WYSIWYG to inform them to either convert their function to a private one or rename it so it doesn't conflict with this module.

hass’s picture

ayalsule’s picture

subscribe

fm’s picture

Status: Closed (fixed) » Active

Was a patch for 6.x-2.2 ever committed?

mari3.14’s picture

Following my post number 35 a little above:

I have been fiddling around with the Google Analytics module Configuration page and in my case the error appeared/disappeared as follows:

Error display:
- When I had selected under "Add segmentation information to tracking code" the first line called 'User Roles'

Error gone:
- Well, as you can image, when I do not select 'User Roles'.

Cheerio,
Maria

Brian Tastic’s picture

I'm adding my voice to this problem. I started getting the error message as stated above, after installing this module. de-activating the module, removes the issue.

I am developing this on a Linux machine, localhost.

I downloaded the latest stable version of the module; v6.2.2

shame, after watching the video intro, I was looking forward to the modules' statistical goodness.

(don't ask me any technical q's, I'm a lightweight at developing, I just install and switch modules on and off - don't laugh!!)

greg.harvey’s picture

I think this is the real problem:
http://drupal.org/node/891514#comment-3441820

Though either this post or that one are probably a dupe. Not sure how WYSIWYG ever ended up in the spotlight... =/

Brian Tastic’s picture

Thanks for your work Greg. I'll be happy to wait for the module to be updated to 6.2.3 before giving it another go. I'm not too much in a rush as still developing the site and initial content.

Thanks also to the module's developer(s) and maintainer(s), as I'm sure it will be an excellent module.

(PS. just to confirm and inform, my LAMP stack is loaded with PHP 5.3)

hass’s picture

it will be an excellent module

It IS, but it will be excellent if You fix Your Drupal incompatible php 5.3 configuration.

greg.harvey’s picture

@hass, did you read http://drupal.org/node/891514#comment-3441820 ?

I don't think it is PHP settings. You shouldn't be 'invoking' profile_load_profile(), as TwoD said here:
http://drupal.org/node/891514#comment-3384366

JimiOBrien’s picture

I'm not running Google Analytics or WYSIWYG and still get the error:

Warning: Parameter 1 to profile_load_profile() expected to be a reference, value given in /var/www/vhosts/site.co.uk/subdomains/sitename/httpdocs/includes/module.inc on line 462

D6.19, php 5.3.3

greg.harvey’s picture

Status: Closed (fixed) » Active

@Jimmy0, then some other module you installed is likely to be making the same mistake and invoking a 'load_profile' hook.Your problem does not belong in this issue. You'll have to work out which module is causing it and raise a bug report there. See #42. ^^

Brian Tastic’s picture

but it will be excellent if You fix Your Drupal incompatible php 5.3 configuration.

@hass, this seems rather harsh. I have read the comments of greg.harvey and his supplied link for further reading and he suggests whilst php5.3 is implicated, it's only because of PHP's namespace implementation and a variable name collision within this module's code.

If this is not the case and you think Greg is wrong, please can you tell me why that would be, and provide details on how I can fix my PHP 5.3 installation.

thanks

fm’s picture

Seems harsh? No, hass's remark was harsh; the tone was impolite and offensive. Moreover, it was materially wrong.

Drupal's System requirements page states:

PHP 5.3 is not yet supported by Drupal 5.x, but is supported by Drupal 6.14 core and higher (see the release notes for 6.14) and also by Drupal 7.x. Note that some contributed modules may not be compatible with PHP 5.3, and that some PHP 5.3 configurations still show warnings with Drupal 6.14; work is ongoing to resolve the latter in #360605: PHP 5.3 Compatibility.

PHP 5.3 has been a "Drupal compatible" configuration since v6.14, released September 16, 2009 -- almost exactly a year ago.

In its current state spewing umpteen lines of warning messages, the Google Analytics module is decidedly not excellent. Though, as Ascenti0n expressed, it can be excellent if this PHP compatibility issue is resolved and the Google Analytics module brought up to date and into line with Drupal's core.

greg.harvey’s picture

It would probably be constructive *not* to turn this in to 'flame a maintainer' day... ;-)

Can someone make a patch for the 6.x-3.x-dev branch so hass can review it?

fm’s picture

No one is flaming the maintainer. If he doesn't have the time or inclination to fix the issue, he should just say so; but saying PHP 5.3 is incompatible with Drupal just isn't true. A civil tone is also desirable.

"Can someone make a patch for the 6.x-3.x-dev branch so hass can review it?"

Seconded.

hass’s picture

Does one of the complainer's really understand the difference between a warning and an error? The answer must be NO.

* Do not complain if you do not understand the difference between warnings (no technical problem, no malfunction) and errors (malfunction).
* Code may give such a PHP warning under PHP 5.3, but is NOT broken!!!
* This module is very very very stable.
* Never use DEV versions if you are not a developer.

Berdir’s picture

That statement ("warnings (no technical problem") is just plain wrong.

It *is* broken and it must be fixed in your module.

It is also not just broken in PHP 5.3, it never worked correctly. Older PHP versions just tried to be nice and assumed that you want to pass the argument by value. However, any changes to the argument are *not* kept. (Unless it's an object in PHP 5, because that is already passed by value (something similar at least) but that is still broken in PHP4).

hass’s picture

Status: Active » Fixed

This warning doesn't break functionality. Never reopen this case again, please.

Status: Fixed » Closed (fixed)

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

OliverColeman’s picture

Status: Closed (fixed) » Closed (won't fix)

This is the stupidest stand-off I've seen on d.o. I wrote a treatise on why this should be considered as breaking the module, but Firefox (you know, that really stable browser...) crashed before I could send it. So the short version: this module produces warning messages on what should be a supported environment (PHP 5.3). A system that produces warning messages tends to make its users think it's broken. I would argue a system that makes its users think it might be broken is not meeting its desired functionality (whether or not it also performs the operations it was intended to perform).

I marked this as "closed (won't fix)" as that seems more accurate than the automatically applied "closed (fixed)". ;)

kenorb’s picture

Title: Warning: Parameter 1 to profile_load_profile() expected to be a reference, value given in module_invoke() » warning: Parameter 1 to profile_load_profile()

I've the same error.

Type: php 
Warning: Parameter 1 to profile_load_profile() expected to be a reference, value given in module_invoke() (line 462 of Sites/coi/public_html/includes/module.inc). 
Backtrace:
_drupal_error_handler(array)[?:?];
.call_user_func_array(array)[module.inc:462];
..module_invoke(array)[googleanalytics.module:101];
...googleanalytics_footer(a:1:{i:0;i:0;})[?:?];
....call_user_func_array(a:2:{i:0;s:22:"googleanalytics_footer";i:1;a:1:{i:1;i:0;}})[module.inc:483];
.....module_invoke_all(a:2:{i:0;s:6:"footer";i:1;i:0;})[theme.inc:1614];
......theme_closure(a:0:{})[?:?];
.......call_user_func_array(a:2:{i:0;s:13:"theme_closure";i:1;a:0:{}})[theme.inc:656];
........theme(a:1:{i:0;s:7:"closure";})[theme.inc:1880];
.........template_preprocess_page(array)[?:?];
..........call_user_func_array(array)[theme.inc:697];
...........theme(array)[context-task-handler.inc:116];
............ctools_context_handler_render(array)[page.inc:335];
.............page_manager_page_execute(a:1:{i:0;s:9:"frontpage";})[?:?];
..............call_user_func_array(a:2:{i:0;s:25:"page_manager_page_execute";i:1;a:1:{i:0;s:9:"frontpage";}})[menu.inc:348];
...............menu_execute_active_handler(a:0:{})[index.php:18];
................index.php

I've PHP 5.3 (MAMP). Using 6.x-2.2
I've massive amount of that warning in watchdog.

kenorb’s picture

Title: warning: Parameter 1 to profile_load_profile() » Warning: Parameter 1 to profile_load_profile() expected to be a reference, value given in module_invoke()
Status: Closed (won't fix) » Active
hass’s picture

Title: warning: Parameter 1 to profile_load_profile() » Warning: Parameter 1 to profile_load_profile() expected to be a reference, value given in module_invoke()
Status: Active » Closed (won't fix)
kenorb’s picture

There was similar issue with RealName: #626350: Real Name problem with php 5.3
They fixed it.

See as well: #360605: PHP 5.3 Compatibility

hass’s picture

Status: Closed (won't fix) » Closed (cannot reproduce)

No patch

kenorb’s picture

Status: Closed (fixed) » Fixed
FileSize
0 bytes

I was using 2.2, it looks like it's fixed in 2.x
http://drupalcode.org/project/google_analytics.git/blobdiff/9c65b6d1ce9d...
I wonder, why nobody mention that.

hass’s picture

Status: Closed (cannot reproduce) » Closed (fixed)
kenorb’s picture

Status: Fixed » Closed (fixed)
FileSize
593 bytes

My patch was as attached, but I see already the same code in dev 6 months ago.
So I'm confused now, why this issue was about.

greg.harvey’s picture

@kenorb: the issue is best described here: http://drupal.org/node/891514#comment-3441820

chefarov’s picture

Version: 6.x-3.x-dev » 6.x-3.5
Status: Closed (fixed) » Active

Problem continues to exist in 5.3 version.
I have:
PHP Version 5.3.3-7+squeeze14
My exact log output is:
Parameter 1 to profile_load_profile() expected to be a reference, value given in /.../includes/module.inc on line 476.

chefarov’s picture

Version: 6.x-3.5 » 6.x-3.x-dev
Status: Active » Closed (fixed)

Wrong post (it was advanced user management module)
sorry! closing again...

kenorb’s picture

Another one was caused by loopfusestatistics module:
http://drupalcode.org/project/loopfuse.git/blame/4a9e3e3c3d020f047112e98...

To see which module causing this, you may try to add the following debug:

--- a/includes/module.inc
+++ b/includes/module.inc
@@ -458,6 +458,9 @@ function module_invoke() {
   unset($args[0], $args[1]);
   $function = $module .'_'. $hook;
   if (module_hook($module, $hook)) {
+    if ($function == 'profile_load_profile') {
+      var_dump(debug_backtrace()); exit;
+    }
     return call_user_func_array($function, $args);

to dump the backtrace on the screen.

In most of the cases, patch like #78 in other modules should fix the problem.