| Project: | User Relationships |
| Version: | 6.x-1.0-rc2 |
| Component: | Code |
| Category: | bug report |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
I have installed the following softwares in my windows xp.
1) xampp-win32-1.7.2.exe
2) drupal-6.14.tar.gz
3) user_relationships-6.x-1.0-rc2.tar.gz
The site is working fine before enabled the following user relationships modules.
UR-API
UR-Blocks
UR-Defaults
UR-Elaborations
UR-Implications
UR-Mailer
UR-Node Access
UR-UI
Some warning alerts display after enabled user relationship modules:
warning: Parameter 2 to user_relationship_defaults_user_relationships() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 471.
warning: Parameter 2 to user_relationship_elaborations_user_relationships() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 471.
warning: Parameter 2 to user_relationship_mailer_user_relationships() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 471.
warning: Parameter 2 to user_relationship_defaults_user_relationships() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 471.
warning: Parameter 2 to user_relationship_elaborations_user_relationships() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 471.
warning: Parameter 2 to user_relationship_mailer_user_relationships() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 471.
warning: Parameter 2 to user_relationship_defaults_user_relationships() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 471.
warning: Parameter 2 to user_relationship_elaborations_user_relationships() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 471.
warning: Parameter 2 to user_relationship_mailer_user_relationships() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 471.
warning: Parameter 2 to user_relationship_defaults_user_relationships() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 471.
warning: Parameter 2 to user_relationship_elaborations_user_relationships() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 471.
warning: Parameter 2 to user_relationship_mailer_user_relationships() expected to be a reference, value given in D:\xampp\htdocs\drupal\includes\module.inc on line 471.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| warning.JPG | 135.33 KB | Ignored: Check issue status. | None | None |
Comments
#1
Due to the upload file type limit, i amended "module.inc" to "module.inc.txt"
Please kindly help. thank you very much
#2
i can't use this user_relationships module. why no one reply me?
can't display the link to add friend
#3
I have a similar error message but mine is related to enabling the Administration Module.
When I enabled this module the following warning appeared:
Parameter 1 to admin_menu_admin_menu() expected to be a reference, value given in C:\xampp\htdocs\&nameofmysite\includes\module.inc on line 471
I have recently installed Drupal 6.14 on localhost. The XAMPP package used for downloading used php version 5.3.0 and I'm running in Window XP
Interestingly, the admin menu has appeared as expected but with the above error message.
Hoping someone can help.
Thanks
SueJ
#4
This is related to PHP 5.3
If you use an earlier version of XAMPP that does not use PHP 5.3 the problem will go away.
I am not sure of the status of a fix in Admin menu.
Izzy
#5
Dear Izzy:
Thanks for this. I wondered if this was the case. I'll get hold of an earlier version of php and see if this solves the problem in the Admin menu.
SueJ
#6
Just upgraded to PHP5.3 and experiencing the same problem. Not really an option for me to rollback unfortunately. Will keep an eye out for a fix.
#7
It's the pass by reference that is causing a problem, i racked my brains out for week with this one, what I did was to open the admin_menu.inc and find any "&$" and change it to "$", that's what giving you the conflict, almost all the modules are affected by this, there are a lot of patches going around for each individual module, try downloading and applying the patch and your problems will go away. or better install xampp with 5.2 :), or just do the above mentioned solution.
im using xampp on win xp machine. running php 5.3
#8
NeIM, thanks for such a clear answer.
Izzy
#9
@izmeez @NelM thanks a lot for posting the solution. Shall we mark it "by design"?
#10
@alex.k with respect, are you kidding?
I thought @NeIM identified the culprit code and it would be considered for the next revision.
I don't understand how this would be "by design" and remain compatible with PHP upgrades.
I will have to leave the status to be determined by the module maintainers.
Izzy
#11
@izmeez I'm not familiar with XAMPP specifically, but passing by reference is perfectly valid PHP. Even more, the code in a lot of places relies on the fact that it's a reference and the changes made will not be lost when the function terminates.
The suggestion to patch drupal core and all modules just can't be right. Which leads me to believe it's specific to certain versions of XAMPP.
#12
Thanks, you may be right. This may have no bearing on User Relationships although it may be a factor for the Admin menu module. There have been similar php 3 related issues in some other module queues such as the date module. Thus I did not think it was XAMPP specific but rather a php 3 issue for modules to consider.
My apologies for my lack of understanding of the User Relationships module.
Izzy
#13
alex.k, yes of course pass-by-reference is valid, but in PHP 5.3 if a function defines one of it's parameters as a reference and you give it a value instead, this causes warnings. The same code is technically wrong in 5.2 too, but in 5.3 it's just much stricter. You can't do this:
<?php
function foo(&$var) {
// do stuff
}
foo('a piece of text');
?>
Passing a string to a function that wants a variable reference is a mistake.
#14
Mark, thanks for the explanation. It does work without warnings on PHP 5.3 on Mac OS, so I guess, XAMPP's settings are stricter by default. Could someone provide a patch that takes care of the warnings on XAMPP?
#15
Yes, it is plausible that the defaults are more lenient.
Open up your php.ini, and under the section "Error reporting", you should set it to error_reporting = E_ALL | E_STRICT and display_errors = On.
In php.ini, on PHP 5.3, you will see each section has a recommended "Development environment" setting, just use those and you should see the error.
It doesn't happen *all the time* though, just I think when rebuilding the menu cache.
#16
Hi Folks. Please check out #615058: Parameter 1 to admin_menu_admin_menu() expected to be a reference. Thanks.
#17
Where are we at with this? Mark explained (#13) that this is clearly going to be a problem going forward with PHP releases.
Has anyone else checked out omo's proposed patch (#16)? I'd like to get at least one success story from someone before I start digging into the source. It just seems like changing the method definition raises a lot of red flags.
#18
I changed the status of this topic to NR because this issue has effected installations on both WAMPServer and XAMPP with no viable solutions or workarounds.
In my tests, changing the error logging (to exclude warning-level entries) does not resolve this issue. Unless there's documentation on why and how-to-resolve I don't see how this can be "by design".
#19
Yes it seems that UR has some code that is not 5.3-friendly. Could one of XAMPP users provide a patch that has corrected the errors? I can't reproduce the issue and don't have XAMPP handy to try.
#20
Sorry, I am not aware of a patch for XAMPP, I reverted to an earlier version of XAMPP.
Izzy
#21
Changing the title to reflect the issue. Looking for a patch to correct this.
#22
Adequate thus excellent patch!!!
Thanks
#23
Thanks. fixed by PHP 5.2
#24
Sort of subscribe, I do have a php53 test environment locally and should be able to provide a patch within a few days.
#25
I'm running Apache and PHP 5.3.0 on OS X Leopard, and I get this error all the time. I get that it's a stricter reporting problem with PHP 5.3, but I don't have a clear idea of how to fix it without touching core, which I'm not going to do. Any ideas anyone?
--Marshall
#26
I can reproduce the problem on php 5.3 and it should, in fact, be reproducible in any php 5.3 setup. I'm really pressed for time right now, and will not be able to prepare and offer a proper patch. As previous posts have pointed out, the main problem is that a number of functions expect their parameters by reference (&$parameter_name) while being called by value (most importantly: being called through module_invoke_all, which does not seem to offer call-by-reference).
For my own setup, I have used a workaround similar to the one linked in comment 16 above, replacing the module_invoke_all by a custom call. My function now looks like this:
function _user_relationships_invoke($type, &$relationship, $is_type = FALSE) {$hook = 'user_relationships'. ($is_type ? '_type' : '');
foreach (module_implements($hook) as $module) {
$function = $module .'_'. $hook;
$result = call_user_func_array($function, array($type, &$relationship));
}
}
Generally, the problem looks like one that would need to be addressed more fundamentally by a maintainer (or the community, of course). This would involve checking if call-by-reference is actually needed (for example, in the user_relationships_ui.module some calls do not seem to require call-by-reference and changing their signature has solved the problem there for me) and eventually either changing the function or changing the place where the function gets called.
Sorry I don't have time for a more thorough analysis right now. If people encountering the same problem can successfully employ the code above to reduce the number of error messages this should probably help others to work on this issue more fundamentally.
#27
@smh67: Youre change is not a workaround, it's the correct solution. module_invoke_all() cannot be used for hooks that contain by reference params. Since we only have two fixed arguments in this case, we don't even need call_user_func_array(). $function($type, $relationship) is much faster and simpler.
Additionally, theme() functions are not allowed to have by reference arguments, that it simply not possible, nor necessary. So I just removed these. Note that this *never* worked, older PHP versions just silently use by value, the only difference is that php 5.3 issues a warning and sets the argument to NULL.
#28
Committed http://drupal.org/cvs?commit=332940. Many thanks!
#29
Automatically closed -- issue fixed for 2 weeks with no activity.
#30
Thank you Berdir your patch worked fine!
#31
Well I'm not sure if I get the whole picture but that's what I get from this thread (and from having the (almost) same problem):
PHP doesn't allow/recommend functions with one of its parameters defined as a reference
PHP 5.3 installed with XAMPP is configured to have: error_reporting = E_ALL | E_STRICT and display_errors = On
some different Drupal modules do not strictly stick to PHP 5 recommendations
All these 3 points make people who have XAMPP installed for development server to get warning messages.
Quite a few solutions are given in this thread but for what I get to understand, 2 can be recommended and only one of them is the more appropriate:
1.- Temp solution: Set up PHP modifying the php.ini file lowering the error reporting level. We'll avoid the warning message to appear
2.- Recommended: Find the 'affected' modules (*), open a issue for each one and wait for it to be repaired
(*) My 'affected' module is 'admin menu' and not 'User Relationships'
I hope this will help and will appreciate any amending to my explanation (for I may be wrong indeed).
#32
1. is not a solution, these errors usually totally break the functionality, you can't simply hide them.
Apart from that, I have no clue how that is related to this issue. The errors in UR have been fixed.
#33
Interesting, I wonder how this will be reflected on the rest of the modules with similar issues - Gmap, for instance.
#34
#7 neim
excellent work, thank you
Apache
MySQL database 5.1.41
PHP 5.3.1