helmut2509

Cannot redeclare....

Recommended Posts

 When calling a page, I get the error (logged in /logs/errors.txt):"Cannot redeclare myfunction..(previously declared in...)"
It seems there is a second declaration of this function, but where?
I already added the namespace Processwire and switched off template compiling,
but to no avail. (PW version 3.0.42)
any ideas?

Share this post


Link to post
Share on other sites

You should check your template file and all include-files (_init.php, _func.php or whatever you use). As the error msg says: you are re-declaring a function somewhere.

With a good IDE you should be able to search across all files and spot it easily.

Share this post


Link to post
Share on other sites

you can get this error if you have only one declaration but you call it multiple times (eg by including it multiple times). maybe you have markup regions turned on? you could use tracy and a simple

bd('test');

to see how often it is called. then you can inspect the backtrace:

bd(debug_backtrace());

Tjxyf3s.png

  • Like 4

Share this post


Link to post
Share on other sites

What is the function name. Is there any chance your function name conflicts with one of the Processwire function or one of the module's function?

Gideon

  • Like 1

Share this post


Link to post
Share on other sites

@helmut2509

Also, do you use URL segments or call $page->render() somewhere? 

Share this post


Link to post
Share on other sites
1 hour ago, helmut2509 said:

I checked the entire project folder: there is only ONE declaration of this function!

No use now that you have checked this, but an FYI for the future, the Tracy Template Resources panel shows you all functions and where they were defined.

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.