Page 1 of 1

Fatal error: Cannot redeclare myFunction()

Posted: Thu Feb 12, 2015 5:28 pm
by Don Chambers
I have two different themes that have an identically names function in config.inc.php. Whenever I switch between these themes, I get this error. Is there a way to avoid this?

Re: Fatal error: Cannot redeclare myFunction()

Posted: Thu Feb 12, 2015 5:34 pm
by garvinhicking
Hey,

hm where exactly does the error happen, what's the exact output?

You could in your config.inc.php use a

Code: Select all

<?php 
if (!function_exists('blabla')) {
 function blabla(...)
}
to wrap a check around your function definition.

However I don't really understand in which case BOTH themes can be loaded at once, it should only always load one theme, not two...

Re: Fatal error: Cannot redeclare myFunction()

Posted: Thu Feb 12, 2015 5:59 pm
by Don Chambers
Here is the scenario: Lets say I am using my theme Kinetic, and has a function named myFunction. Then I switch to a different theme named "Clean", which also has this function named myFunction. As soon as I select this second theme, I get the error:

Fatal error: Cannot redeclare myFunction() (previously declared in /var/www/vhosts/com/templates/clean/config.inc.php:11) in /var/www/vhosts/com/templates/kinetic/config.inc.php on line 33.

I can use my browser "back" button to get back to the admin page, and everything is fine from that point forward. There is no further notice or error - it only happens when I initially select a theme that has a function with the same name as the theme I just switched from. It is as if for that brief moment, both theme's configs are loaded.