Hi if i declare a function in the setup code and then use the view with this field inside another view with the Views field view module then i geht the error Fatal error: Cannot redeclare myfunction() (previously declared in ...\sites\all\modules\views_php\plugins\views\views_php_handler_field.inc(117) : runtime-created function:1) in ...\sites\all\modules\views_php\plugins\views\views_php_handler_field.inc(117) : runtime-created function on line 1

There seems to be an namespace conflict with the runtim-created function that redeclared themself in this case.

Comments

darshanchoudhary’s picture

Hi,

Did you find any solution for this..I am also getting the same error when i declare a function in Output code.

tfranz’s picture

Issue summary: View changes

I had the same problem when declaring a function in the field "Setup Code".
My solution was to NOT "Use setup code" and instead writing everything into "Filter code".

(Interesting: the error appeared after a while and not directly. Could be like something like a caching-problem? I switched of caching, but the error still persisted until i disabled the "Setup Code".)

StephenN’s picture

not sure of the root cause but the simple fix is to wrap your function definition inside an if(!function_exists('name_of_function')){ statement