Everything was working very fine with my site when suddenly I received the following error afrer accessing my main page:
Fatal error: Only variables can be passed by reference in /home/aladdinw/public_html/sites/test.aladdinweb.net/modules/localizer/localizer.module on line 779
I have discovered that after I delete my php.ini file in that folder the problem disappears. And of course if I deactivate localizer, the problem disappears too.
Isn't is weird???

Comments

ray007’s picture

Maybe not necessary in php5, but in php4 I think functions wanting to return references to static objects should be declared doing so, i.e.:

function &localizer_get_contentlocales($force=FALSE) {

note the ampersand before the functionname.
If I'm right with that, we have a few more offenders.

the offending line from the bug report (line 788 in latest cvs) is

      $contentlocale = key(localizer_get_contentlocales($force));

and should probably be changed to something like

      $k =& localizer_get_contentlocales($force);
      $contentlocale = key($k);

good/bad/nonsense?

palazis’s picture

well i am using php5 and localizer 5.1-1.7
i can't tell, perhaps you're right...
but sorry what do you mean by good/bad/nonsense???

ray007’s picture

The last line was just meant to gather comments, since I wrote all just in the web-form here and didn't actually test any of it.
Does the 2-line fix work for you?

palazis’s picture

thanks for the (fast) answer. i tried different things.
theoritically i understand what you say about references...
but practically, no i was not able to find these EXACT pieces of code in line 788.
this is what i did:
LINE 779 of localizer.module file - I commented out the line of code there:
// $nodelocale = key(localizer_get_nodeslocales($force));
and i added after that:
$k = & localizer_get_nodeslocales($force);
$nodelocale = key($k);
Everyting works OK now but I have no idea if there are other changes neccessary (eg in other functions)
???

ray007’s picture

My comment about line 788 was for Roberto, if he wanted to fix it in the (at the time) latest cvs version.

Since you're using php5 you should be fine now, I believe may we have to do some more work regarding references for drupal installations running on php4. I need to read the chapter regarding differences with references between php4 and 5 again ...

Roberto Gerola’s picture

I have some installations with PHP4 and Localizer, but I have not encountered these errors.
I'll take a deeper look to PHP 4 documentation, in every case.

Roberto Gerola’s picture

Static variables are passed in PHP4 by reference and the operator & should be implied.

Can you try this ? :
$k = localizer_get_nodeslocales($force);
$nodelocale = key($k);

Thanks !

ray007’s picture

> Static variables are passed in PHP4 by reference and the operator & should be implied.

Says who?
Static variables are implemented as references in php4 (see http://de.php.net/manual/en/language.variables.scope.php) ... says nothing about their passing around afaict.

> Can you try this ? :
> $k = localizer_get_nodeslocales($force);
> $nodelocale = key($k);

This should work since you're not trying to modify the array returned by localizer_get_nodeslocales($force);

Roberto Gerola’s picture

>This should work since you're not trying to modify the array returned by localizer_get_nodeslocales($force);
Well. So we have more offending points to fix.

sun’s picture

Status: Active » Fixed

localizer_get_nodeslocales() no longer exists. So this should be fixed in latest development snapshot.

Anonymous’s picture

Status: Fixed » Closed (fixed)