I have installed the Premium Module for 5.x When I try to restrict access on pages containing PHP codes , the page throws a fatal error when viewed in anonymous mode. On logging in the page works as expected. It says that there is a redeclaration of a function in common.inc file. I have renamed the function in my PHP code but it still shows the message.
I tried the same thing in my local server but didn't get any error anywhere.
How do I correct this?

Comments

coreyp_1’s picture

Weird. It sounds like for some reason the PHP is getting parsed twice, which indeed would throw that error. You might file a bug report on the Premium module's issue tracker page.

A quick work-around would be something like this: use PHP's function_exists() to protect your code. This will keep the function from being declared twice.

if (!function_exists("foo") {
  function foo ($bar) {
    return $something_interesting;
  }
}

- Corey

rsomaskandan’s picture

Corey, I added if(!function_exists) to my code and it didnt throw any error but what is even stranger is that the premium module didn't work at all after adding it....It shows the page to all users including anonymous users.

RS.

coreyp_1’s picture

Maybe it's because I left out a ")" in the code above... grrrr....

if (!function_exists("foo")) {

If that doesn't work, then I'm not sure... I've never used the Premium module myself.

- Corey

rsomaskandan’s picture

Corey,

I added the parantheses but still doesn't work.

Thanks for your help....

RS